All pastes #483033 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-05-11 15:13 UTC
rendered paste body
immagine the .h file looks like this 

class MyClass {

void Insert(char *key);
char *Get();

};

your .cpp file would look like this

declspec(DLLEXPORT) void *MyClass_Create() {
      MyClass *mc = new MyClass();
      return mc;
}

declspec(DLLEXPORT) void MyClass_Delete(void *InstancePtr) {
         MyClass *c = InstancePtr;
        delete c;
}

declspec(DLLEXPORT) void MyClass_Insert(void *InstancePtr,char *key) {
     MyClass *inst = (MyClass*) InstancePtr;
     inst->Insert(key);

}

and so on

then in your C# file 
you can use

[DllImport("MyClass.dll", EntryPoint="MyClass_Insert", ExactSpelling=false,
			 SetLastError=true)]
		static extern void MyClass_Insert(
			[MarshalAs(UnmanagedType.IntPtr)] IntPtr InstancePtr,
			[MarshalAs(UnmanagedType.CharArray)] byte[] String);

to call the method 
hope this helps