How to use C# dll in C++?

  • Thread starter Thread starter theChameleon
  • Start date Start date
T

theChameleon

Guest
myDLL.dll was generated from IKVM. Use in C# project is perfectly fine.

HOW to:

1. call a static method in C++. in C# code, it is `com.myApp.Initialiser.initialise(object, string, int)`
2. create a new instance in C++. in C# code it is `new com.myApp.requests.MyRequest()`

Code:

#include "stdafx.h"
#include <iostream>
using namespace std;
#include <stdio.h>
#include <cstring>
#include <string>
#include <windows.h>

typedef void (*Initialise)(void*, std::string, int);

int main(){
HINSTANCE myDLL = LoadLibrary(TEXT("myDLL.dll"));
HINSTANCE ikvmCoreDLL = LoadLibrary(TEXT("IKVM.OpenJDK.Core.dll"));

if(myDLL && ikvmCoreDLL){
cout << "dlls loaded" << endl;
//how to do 1 and 2 using myDLL.dll?

Initialise ptr = (Initialise) GetProcAddress(myDLL, "initialise"); //not working
}

return 0;
}


Continue reading...
 
Back
Top