本文介绍了使用DLL而不导入LIB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 大家好, 我有一个用VC ++ 2005编写的应用程序,我创建了一个DLL(导出一个函数) 我的DLL中的代码如下:Hi all,I have an application written in VC++ 2005 and i create a DLL (exporting a single function)The Code in my DLL is as below :#include <stdio.h>#include <atlstr.h>extern "C"{__declspec(dllexport) void DisplayHelloFromDLL(){CString str;printf ("Hello from DLL !\n");}} 问题是我想通过导入生成的LIB从我的DLL导入函数我不知道如何在VC2005中这样做。 Plz有人帮助我或给我一个线索。 ThxThe prob is i wanna import the Function from my DLL withour Importing the generated LIB and i dont know how to do that in VC2005.Plz somebody help me or guive me a clue. Thx推荐答案typedef VOID (CALLBACK* LPFN_DHFDLL)();HINSTANCE hInst = ::LoadLibrary(_T("MyLib.dll"));if (NULL != hInst){ LPFN_DHFDLL pDisplayHello = (LPFN_DHFDLL)::GetProcAddress(hInst, "DisplayHelloFromDLL"); if (pDisplayHello) pDisplayHello(); ::FreeLibrary(hInst);}#include <windows.h>// Declaring Function pointer for DisplayHelloFromDLLtypedef void ( WINAPIV* LPFN_DISPLAYHELLO ) ( );void main(){ // Loading DLL HINSTANCE hMyDLL = LoadLibraryA("Dll_New.dll"); // Getting address of the DLL exported function LPFN_DISPLAYHELLO fnDisplayName = (LPFN_DISPLAYHELLO)GetProcAddress( hMyDLL, "DisplayHelloFromDLL" ); // Actual function call fnDisplayName(); // Releasing DLL FreeLibrary( hMyDLL );} 这篇关于使用DLL而不导入LIB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-24 08:03