请问怎么自定义使用user32.dll里的windows API LoadLibrary GetProcAddress FreeLibrary 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 // A simple program that uses LoadLibrary and // GetProcAddress to access myPuts from Myputs.dll. #include <windows.h> #include <stdio.h> typedef int (__cdecl *MYPROC)(LPWSTR); VOID main(VOID) { HINSTANCE hinstLib; MYPROC ProcAdd; BOOL fFreeResult, fRunTimeLinkSuccess = FALSE; // Get a handle to the DLL module. hinstLib = LoadLibrary(TEXT("myputs")); // If the handle is valid, try to get the function address. if (hinstLib != NULL) { ProcAdd = (MYPROC) GetProcAddress(hinstLib, "myPuts"); // If the function address is valid, call the function. if (NULL != ProcAdd) { fRunTimeLinkSuccess = TRUE; (ProcAdd) (L"Message sent to the DLL function\n"); } // Free the DLL module. fFreeResult = FreeLibrary(hinstLib); } // If unable to call the DLL function, use an alternative. if (! fRunTimeLinkSuccess) printf("Message printed from executable\n"); }MSDN 你可以用vc2012等,一样支持VC不需要.net framework 楼上正解,VisualStudio的任何版本中的VC++都不依赖.net framework,除非你明确的新建了一个C++/CLR项目,除非是需要维护VC6.0写的一堆老代码,否则没必要抱着VC6.0不放了。自行定义的方法是先安装高版本的VisualStudio,从里面找到头文件,复制粘贴过去,但这仅限于一些数值型的宏定义,如果是函数没有的话,还是只能用一楼的方法了,结构体也不好处理,直接改头文件可能导致链接器报错,总之很麻烦,对初学者来说更是雪上加霜 谢谢,追问一下,使用vb.net 或者 c# 是做界面相关的,有没有可能不需要.net framework? 不行,VB.NET和C#必须用.net framework。不过2014年微软发布的.NET Native可以将C#程序编译为本机代码而脱离.net运行,不过目前还属于实验性产品,限制非常多,只支持VisualStudio2013,只支持ARM 或 x64 架构,只支持 Windows 商店应用程序开发http://developer.51cto.com/art/201404/434924.htm 追加指针长度问题 CAsyncSocket receive之前有没有办法知道将要获取的数据大小 构造函数怎么重载? 怎么取得系统托盘的图标?(200分)顶者有分 list 控件中如何加入长度为40的字符串. 一个难题?在VC中使用水晶报表。详情请进! 两个控件‘LIST ’‘Data Time Picker’? 求牛人大大看看该怎样处理。。。 关于windows下编译libxml2的问题 怎样判断两张图片的某个显示区域是否相等? 我是菜鸟 问一个简单的问题 我把控件工具条关闭之后就再也找不到了 怎么办? ****** 在Exe和Dll中调用ADO有何不同 ******
// GetProcAddress to access myPuts from Myputs.dll.
#include <windows.h>
#include <stdio.h>
typedef int (__cdecl *MYPROC)(LPWSTR);
VOID main(VOID)
{
HINSTANCE hinstLib;
MYPROC ProcAdd;
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
// Get a handle to the DLL module.
hinstLib = LoadLibrary(TEXT("myputs"));
// If the handle is valid, try to get the function address.
if (hinstLib != NULL)
{
ProcAdd = (MYPROC) GetProcAddress(hinstLib, "myPuts");
// If the function address is valid, call the function.
if (NULL != ProcAdd)
{
fRunTimeLinkSuccess = TRUE;
(ProcAdd) (L"Message sent to the DLL function\n");
}
// Free the DLL module.
fFreeResult = FreeLibrary(hinstLib);
}
// If unable to call the DLL function, use an alternative.
if (! fRunTimeLinkSuccess)
printf("Message printed from executable\n");
}
MSDN
不需要.net framework
不过2014年微软发布的.NET Native可以将C#程序编译为本机代码而脱离.net运行,不过目前还属于实验性产品,限制非常多,只支持VisualStudio2013,只支持ARM 或 x64 架构,只支持 Windows 商店应用程序开发
http://developer.51cto.com/art/201404/434924.htm