Writing a DLL For Use With rundll32.exe

2019-09-11 10:49发布

问题:

I have the following codes:

mydll.h:

#include <Windows.h>

__declspec(dllexport) void CALLBACK Entry(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow);

mydll.c:

#include "mydll.h"

void CALLBACK Entry(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) {
    FILE *f;
    f = fopen("C:\\Users\\user\\Desktop\\test.txt", "rw");
    fprintf(f, "test");
    fclose(f);
}

It compiles to mydll.dll.

Then, when I try to do

rundll32.exe mydll.dll,Entry

It gives me the error message

Error in mydll.dll
Missing entry: Entry

What am I missing here?