试试include一下windows.h
方便的话把你代码贴出来看看吧
方便的话把你代码贴出来看看吧

无为而为 && 每天进步一小点...
程序代码://dll_1.h #ifdef __cplusplus #define EXPORT extern "C" __declspec(dllexport) #else #define EXPORT __declspec(dllexport) #endif//__cplusplus EXPORT int in_1(void); EXPORT int out_1(void);//
程序代码://dll_1.c
#include <Windows.h>
#include "dll_1.h"
int WINAPI DllMain(HINSTANCE hInstance,
DWORD fdwReason,
PVOID pvReserved)
{
return TRUE;
}
EXPORT int in_1()
{
return 1;
}
EXPORT int out_1()
{
return 2;
}//
程序代码://dll_2.h #ifdef __cplusplus #define EXPORT extern "C" __declspec(dllexport) #else #define EXPORT __declspec(dllexport) #endif//__cplusplus EXPORT int in_2(void); EXPORT int out_2(void);//
程序代码://dll_2.c
#include <Windows.h>
#include "dll_2.h"
int WINAPI DllMain(HINSTANCE hInstance,
DWORD fdwReason,
PVOID pvReserved)
{
return TRUE;
}
EXPORT int in_2()
{
int i = 0;
HMODULE h = NULL;
int (*fun)(void);
SetDllDirectory(TEXT("E:\\Project\\DLL1"));
h = LoadLibrary(TEXT("dll_1"));
if (h)
{
fun = (int (__cdecl *)(void)) GetProcAddress(h, "in_1");
i = 2*fun();
FreeLibrary(h);
}
return i;
}
EXPORT int out_2()
{
int i = 0;
HMODULE h = NULL;
int (*fun)(void);
SetDllDirectory(TEXT("E:\\Project\\DLL1\\dll_1"));
h = LoadLibrary(TEXT("dll_1"));
if (h)
{
fun = (int (__cdecl *)(void)) GetProcAddress(h, "out_1");
i = 2*fun();
FreeLibrary(h);
}
return i;
}//
程序代码://dll_3.h #ifdef __cplusplus #define EXPORT extern "C" __declspec(dllexport) #else #define EXPORT __declspec(dllexport) #endif//__cplusplus EXPORT int in_3(void); EXPORT int out_3(void);//
程序代码://dll_3.c
#include <Windows.h>
#include "dll_3.h"
int WINAPI DllMain(HINSTANCE hInstance,
DWORD fdwReason,
PVOID pvReserved)
{
return TRUE;
}
EXPORT int in_3()
{
int i = 0;
HMODULE h = NULL;
int (*fun)(void);
SetDllDirectory(TEXT("E:\\Project\\DLL1\\dll_1"));
h = LoadLibrary(TEXT("dll_1"));
if (h)
{
fun = (int (__cdecl *)(void)) GetProcAddress(h, "in_1");
i = 3*fun();
FreeLibrary(h);
}
return i;
}
EXPORT int out_3()
{
int i = 0;
HMODULE h = NULL;
int (*fun)(void);
SetDllDirectory(TEXT("E:\\Project\\DLL1"));
h = LoadLibrary(TEXT("dll_1"));
if (h)
{
fun = (int (__cdecl *)(void)) GetProcAddress(h, "out_1");
i = 3*fun();
FreeLibrary(h);
}
return i;
}//
程序代码://DLL_APP.c
#include <Windows.h>
#include <strsafe.h>
int WINAPI WinMain(HINSTANCE hInstace,
HINSTANCE PrevhInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
HMODULE hDll_1 = NULL, hDll_2 = NULL, hDll_3 = NULL;
int (*fun)(void);
TCHAR buff[128] = {0};
hDll_1 = LoadLibrary(TEXT("E:\\Project\\DLL1\\dll_1"));
hDll_2 = LoadLibrary(TEXT("E:\\Project\\DLL2\\dll_2"));
hDll_3 = LoadLibrary(TEXT("E:\\Project\\DLL3\\dll_3"));
if (!hDll_1 || !hDll_2 || !hDll_3)
{
MessageBox(NULL, TEXT("error..."), TEXT("msg"), 0);
return -1;
}
fun = (int (*)(void))GetProcAddress(hDll_1, "in_1");
StringCchPrintf(buff, _countof(buff), TEXT("int in_1(void) = %d\n"), fun());
MessageBox(NULL, buff, TEXT("msg"), 0);
fun = (int (*)(void))GetProcAddress(hDll_1, "out_1");
StringCchPrintf(buff, _countof(buff), TEXT("int out_1(void) = %d\n\n"), fun());
MessageBox(NULL, buff, TEXT("msg"), 0);
fun = (int (*)(void))GetProcAddress(hDll_2, "in_2");
StringCchPrintf(buff, _countof(buff), TEXT("int in_2(void) = %d\n"), fun());
MessageBox(NULL, buff, TEXT("msg"), 0);
fun = (int (*)(void))GetProcAddress(hDll_2, "out_2");
StringCchPrintf(buff, _countof(buff), TEXT("int out_2(void) = %d\n\n"), fun());
MessageBox(NULL, buff, TEXT("msg"), 0);
fun = (int (*)(void))GetProcAddress(hDll_3, "in_3");
StringCchPrintf(buff, _countof(buff), TEXT("int in_3(void) = %d\n"), fun());
MessageBox(NULL, buff, TEXT("msg"), 0);
fun = (int (*)(void))GetProcAddress(hDll_3, "out_3");
StringCchPrintf(buff, _countof(buff), TEXT("int out_3(void) = %d\n\n"), fun());
MessageBox(NULL, buff, TEXT("msg"), 0);
FreeLibrary(hDll_1);
FreeLibrary(hDll_2);
FreeLibrary(hDll_3);
return 0;
}