1
0

callcdr.cpp 927 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #import "VGCoreAuto.tlb"
  2. #include <Windows.h>
  3. #define corel VGCore::IVGApplication
  4. using namespace VGCore;
  5. void Call_CorelDRAW();
  6. bool fill_red(corel *cdr);
  7. corel *cdr = NULL;
  8. int main() {
  9. HRESULT hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
  10. if (SUCCEEDED(hr)) {
  11. try {
  12. Call_CorelDRAW();
  13. } catch (_com_error &e) {
  14. MessageBox(NULL, e.Description(), "Error", MB_ICONSTOP);
  15. }
  16. CoUninitialize();
  17. }
  18. return 0;
  19. }
  20. void Call_CorelDRAW() {
  21. IVGApplicationPtr app(L"CorelDRAW.Application.16"); // 我的电脑 X6 正常 ; 毛子版 CorelDRAW 2020 绑定不上,没法使用
  22. app->Visible = VARIANT_TRUE;
  23. auto doc = app->ActiveDocument;
  24. if (!doc)
  25. doc = app->CreateDocument();
  26. cdr = app;
  27. fill_red(cdr);
  28. }
  29. bool fill_red(corel *cdr) {
  30. auto sr = cdr->ActiveSelectionRange;
  31. auto red = cdr->CreateCMYKColor(0, 100, 100, 0);
  32. sr->ApplyUniformFill(red);
  33. return true;
  34. }