#include <windows.h> int i=0; extern "C" _declspec(dllexport) void dec2yyy(int yyy,int source,char* bin) { if(source==0) return; dec2yyy(yyy,source/yyy,bin); if((source%yyy)<10) bin[i]=(char)(source%yyy+0x30); else bin[i]=(char)(source%yyy+0x37); i++; } BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call,LPVOID lpReserved) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: { // } case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; }我就是这么调用的 这是dll中的
#include<stdio.h> #include<windows.h> int main() { HINSTANCE hDllInst = LoadLibrary("dlltest.DLL"); typedef void (WINAPI *MYFUNC)(int,int,char*); MYFUNC mydec2yyy = NULL; mydec2yyy = (MYFUNC)GetProcAddress(hDllInst,"dec2yyy"); char s[20]; for(int i=0;i<20;i++) s[i]='\0'; mydec2yyy(16,258,s); printf("%s\n",s); FreeLibrary(hDllInst); return 0; }这是调用者函数