1

I've got one third-party dll library which I have to work with. The following pretty simple delphi code does the job:

var
 CCPActiveX:variant;
begin
 CCPActiveX:=CreateOleObject('CCP.CCPActiveX');
 CCPActiveX.CCP_Init('arg1','arg2');
 //...
 CCPActiveX:=unassigned;
end;

However I'd love to have the samething work on C#. I tried to import dll methods like this:

class CCP
{
    [DllImport("CCP.dll")]
    private static extern int CCP_Init(string arg1, string arg2);

    public static int Init(string arg1, string arg2)
    {
        return CCP_Init(arg1, arg2);
    }
}

However it results into Can't find DLL entry point exception.

I also tried to specify the entry point differently, say:

  1. [DllImport("CCP.dll", EntryPoint = "CCP.CCPActiveX.CCP_Init")]
  2. [DllImport("CCP.dll", EntryPoint = "CCPActiveX.CCP_Init")]

and so on. But nothing changed.

I tested delphi code on Windows xp x86. And the C# code - on Windows 7 x64. On both OSs the dll is sucessfully registered with regsvr32.exe. What am I doing wrong?

horgh
  • 17,918
  • 22
  • 68
  • 123
  • 1
    That's just not how COM works. The DLL does not export a function named `CCP_Init`. The functions that it exports are, at a minimum, `DllCanUnloadNow, DllGetClassObject, DllRegisterServer, DllUnregisterServer` – David Heffernan Sep 26 '13 at 10:02

0 Answers0