1

I usually use COM reference to connect to CorelDRAW. Every version of Corel create specific interop dll (CorelDRAW Type Library and VGCore Type Library). If I want to change Corel version between X3-X6 then I must change those 2 dlls.

Of Course I can connect directly to any version of Corel using this:

 Dim obj As Object

 obj = DirectCast(Activator.CreateInstance(Type.GetTypeFromCLSID(New Guid(guidNo))), Object)

Where "guidNo" is as string with specific GUID to connect to specific Corel Version. It works but... I need to create object in CorelDraw types like "Shape", "Segment", etc.

If I will try to use existing CorelDRAW.Application object (for example from version X3) and connect to X6 using it then some things will no longer work. But It is strange that I can do anything using this method.

miQ
  • 21
  • 1
  • 7
  • There is no magic solution, you'll need more of those Activator.CreateInstance() calls. It is a very painful way to write code, you shouldn't really consider it. Only a company like Microsoft knows how to create COM servers that are compatible across versions over many years, a very difficult feat. Most if not all of your code will be the same, you just need different projects with different references. Perhaps unpleasant but it is manageable. – Hans Passant Apr 09 '15 at 14:32
  • @HansPassant Is using "dynamic" (http://stackoverflow.com/q/2889974/57428) a good idea here? – sharptooth Apr 09 '15 at 15:42
  • @Hans Passant: Well I can replace two interop dll's and change version like this but usualy there is no way to write anything in "Program Files". Only admin may do this. Unless I will use SetACL (https://helgeklein.com/setacl/documentation/command-line-version-setacl-exe/) I have it in my project to add permitions to "programData\myProgDir\" and to add some content in HKLM in registry (admin is needed only one time). Now when user wants to use other version of Corel then he/she must install my app again. NSIS changes those 2 dlls and work is done. – miQ Apr 09 '15 at 15:50
  • @sharptooth: Main problem is that I can't add more then one reference to Corel in the same time. So If I use X3 and want to use X4 then I must close my app, replace two dll's and run it again. Like I said I may replace those Interop files directly after closing my app (using other exe) but if I would be able to change path to interop dll then I would be able to do it from my exe file. – miQ Apr 09 '15 at 16:13
  • hmmm... maybe this will be solution: `AppDomain.CurrentDomain.AppendPrivatePath("x3")`. I must check this. Only problem is that AppendPrivatePath is obsolete... – miQ Apr 09 '15 at 17:06
  • YES!!! Problem solved. I have try this: ` AppDomain.CurrentDomain.AppendPrivatePath("Corel\\" & IO.File.ReadAllText("CorelVer.txt"))` and it works perfectly. No I only need to write selected version to registry and all will works. When file have value 'x3' then it runs files from directory: .\Corel\x3\. When I change value to x5 then I have to reboot aplication to get working Corel X5. That is fantastic! – miQ Apr 09 '15 at 19:21
  • There is a way to work with any version of Corel. Program must have separated dll library that will interact with Corel. Then privatePath must be changed before creating CorelDRAW.Application object. In my app this was problematic. My external library have many User Controls that exist in main application. To solve this problem I had to disable framework in project properties and run my Form from Sub Main. Now I may run any supported Corel version that I want. – miQ Apr 14 '15 at 12:26

0 Answers0