How do I call a .dll and declare functions in C ++ .Net

3

I'm migrating a project to C ++, but I'm having trouble calling .dll

This is code:

int  LoadDLL (void) {
   char handle;

   //! Carrega a dll ...
   handle = LoadLibrary(L"c:\windows\system\minhadll.dll");

   //! Verifica se a dll foi corretamente carregada..
   if (handle) {

   }
   return handle; 
}

The error is in the "=" of the handle:

  

"IntelliSense: A value of type" HMODULE "can not be assigned to an entity of type" int ""

What am I doing wrong, and what do you recommend?

    
asked by anonymous 05.12.2014 / 20:23

1 answer

3

For the comments, I believe the problem is in the handle declaration:

HMODULE LoadDLL(void) {
   HMODULE handle;

   // Carrega a dll ...
   handle = LoadLibrary(L"c:\windows\system\minhadll.dll");

   // Verifica se a dll foi corretamente carregada..
   if (handle == NULL) {
      //Indicar que deu erro
   }
   return handle; 
}

Notice that I've changed the verification code for the error case, see if that's what you want.

    
05.12.2014 / 20:34