how to pass pointers to a function in C

user204415

What I want to do is to put DLLname where DLLnameHERE.dll is.

This is a piece of my code:

int ToLoadLibrary(char * DLLname) 
{

HINSTANCE hinstLib;
MYPROC ProcAdd;
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;

// Get a handle to our DLL module created in the previous example. Make sure you already copied the mydllpro.lib and mydllpro.dll to the appropriate folders...
hinstLib = LoadLibrary(L"DLLnameHERE.dll");

Thanks in advance.

Wintermute

The problem you run into is a Microsoft-specific one. The macro LoadLibrary expands, depending on preprocessor macros, either to the name of a function that accepts a char const* or a wchar_t const *. In your case, the call

hinstLib = LoadLibrary(L"DLLnameHERE.dll");

suggests that the latter is the case.

The easiest way around this problem is to use the name of the function that accepts char const * directly; it is LoadLibraryA:

hinstLib = LoadLibraryA(DLLname);

The mechanism is described in greater detail here in the MSDN.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

pass pointers to pointers to function

From Dev

pass pointers to pointers to function

From Dev

How to pass array of function pointers to another function

From Dev

C++ pass pointers to a Template class function

From Dev

How do I pass a closure through raw pointers as an argument to a C function?

From Dev

How to pass a structure into a function to print using pointers and dynamic memory [C-Programming]

From Dev

how to pass 2D arrays through a function without using pointers in C

From Dev

How to pass an array of pointers, and to let the function find the size of array?

From Dev

how to pass both function pointers and lambda's using one interface

From Dev

how to pass both function pointers and lambda's using one interface

From Dev

How can i pass a character array to a function using pointers?

From Java

How do function pointers in C work?

From Dev

C - How to setup an associative array of function pointers?

From Dev

C - how to modify an array of pointers inside of a function

From Dev

How are arguments passed to function pointers in C?

From Dev

Pointers as function arguments in C

From Dev

C array of function pointers

From Dev

setting function pointers C

From Dev

C -- Array of Function Pointers

From Dev

Function pointers C

From Dev

Clarification on function pointers in C

From Dev

Function pointers in C++

From Dev

Function pointers table in C

From Dev

C -- Array of Function Pointers

From Dev

Understanding c function pointers

From Dev

Function Pointers in C and their behaviour

From Dev

Pointers and pass by reference c++

From Dev

Pass container of raw pointers and smart pointers to template function

From Dev

How to do an OCaml binding to a C function with an array of void pointers as a parameter

Related Related

  1. 1

    pass pointers to pointers to function

  2. 2

    pass pointers to pointers to function

  3. 3

    How to pass array of function pointers to another function

  4. 4

    C++ pass pointers to a Template class function

  5. 5

    How do I pass a closure through raw pointers as an argument to a C function?

  6. 6

    How to pass a structure into a function to print using pointers and dynamic memory [C-Programming]

  7. 7

    how to pass 2D arrays through a function without using pointers in C

  8. 8

    How to pass an array of pointers, and to let the function find the size of array?

  9. 9

    how to pass both function pointers and lambda's using one interface

  10. 10

    how to pass both function pointers and lambda's using one interface

  11. 11

    How can i pass a character array to a function using pointers?

  12. 12

    How do function pointers in C work?

  13. 13

    C - How to setup an associative array of function pointers?

  14. 14

    C - how to modify an array of pointers inside of a function

  15. 15

    How are arguments passed to function pointers in C?

  16. 16

    Pointers as function arguments in C

  17. 17

    C array of function pointers

  18. 18

    setting function pointers C

  19. 19

    C -- Array of Function Pointers

  20. 20

    Function pointers C

  21. 21

    Clarification on function pointers in C

  22. 22

    Function pointers in C++

  23. 23

    Function pointers table in C

  24. 24

    C -- Array of Function Pointers

  25. 25

    Understanding c function pointers

  26. 26

    Function Pointers in C and their behaviour

  27. 27

    Pointers and pass by reference c++

  28. 28

    Pass container of raw pointers and smart pointers to template function

  29. 29

    How to do an OCaml binding to a C function with an array of void pointers as a parameter

HotTag

Archive