user1432966 user1432966 - 1 year ago 105
C Question

Getting response of a DLL in C

I've follow the next tutorial:

It is working fine for me. But I need to printf the response of the callbackfunctions:


I get the error:
cannot convert argument 1 from 'UINT' to 'const char *const '

I've tried another options:

printf(Convert.ToString(uReturnVal)); //ERROR :'Convert': undeclared identifier [


printf(uReturnVal->ToString()); //ERROR: '->ToString' must point to class/struct/union/generic


printf(uReturnVal.ToString());//error: /ERROR: '->ToString' must point to class/struct/union/generic

This is the code of the tutorial:


HINSTANCE hDLL; // Handle to DLL
LPFNDLLFUNC1 lpfnDllFunc1; // Function pointer
DWORD dwParam1;
UINT uParam2, uReturnVal;

hDLL = LoadLibrary("MyDLL");
if (hDLL != NULL)
lpfnDllFunc1 = (LPFNDLLFUNC1)GetProcAddress(hDLL,
if (!lpfnDllFunc1)
// handle the error
return true;
// call the function
uReturnVal = lpfnDllFunc1(dwParam1, uParam2);

Many thanks in advance.

Answer Source

First argument to printf functions is always format specifier. In your case printf("%u\n",uReturnVal) should work. See Format Specification Syntax: printf and wprintf Functions.

To Expand: The code above is pure C.

You can also do it in C++ style, even more elegant:

#include <iostream>
  uReturnVal = lpfnDllFunc1(dwParam1, uParam2);
std::cout << "Result is: " << uReturnVal << std::endl;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download