I have a function in the DLL:

extern "C" __declspec(dllexport) void test(char *text, len); 

How to correctly call it from the command line? While trying to do this:

 rundll32 mydll.dll,test "string" 6 

    1 answer 1

    Read the description of how to use rundll32 . In short - not any function can be called from the library, but strictly following certain conventions described in the article by reference.

    If in simple and in Russian, then rundll32 only supports functions with the following signature:

     void CALLBACK EntryPoint(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow); 

    Pay attention to the arguments and to the fact that the f-tion should follow the _stdcall , not _cdecl .

    • Is such a record possible? extern "C" __declspec (dllexport) void CALLBACK test (HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow); Otherwise, he simply does not see the export function .. - nullptr
    • one
      in theory this will be enough. 1. extern "C" tells the compiler not to spoil the name of the function; 2. __declspec(dllexport) puts the __declspec(dllexport) into the DLL export table; 3. CALLBACK actually hides in itself that it is _stdcall , i.e. order parsing and passing arguments f-tion. - gecube