想写一个下载程序,用URLDOWNLOADTOFILE比较容易实现,调式时却发现得不到API地址,郁闷,大家帮忙看看问题出在哪,代码非常简单。
#pragma comment(linker,"/ENTRY:main")#include <windows.h>
typedef int (__stdcall * PFN_URLDOWNLOADTOFILE)(LPUNKNOWN, LPCTSTR, LPCTSTR, DWORD,LPBINDSTATUSCALLBACK);
int main (void *)
{
HINSTANCE hurlmon = LoadLibrary("urlmon.dll");
PFN_URLDOWNLOADTOFILE pfnurldown;
if(!(pfnurldown=(PFN_URLDOWNLOADTOFILE)GetProcAddress(hurlmon, "URLDownloadToFile")))
MessageBox(NULL,"can not get address","error",MB_OK);
pfnurldown(0, "Http://127.0.0.1/test.exe", "c:\\test.exe", 0, 0);
WinExec("c:\\test.exe", SW_SHOW);
ExitThread(0);
}
#pragma comment(linker,"/ENTRY:main")#include <windows.h>
typedef int (__stdcall * PFN_URLDOWNLOADTOFILE)(LPUNKNOWN, LPCTSTR, LPCTSTR, DWORD,LPBINDSTATUSCALLBACK);
int main (void *)
{
HINSTANCE hurlmon = LoadLibrary("urlmon.dll");
PFN_URLDOWNLOADTOFILE pfnurldown;
if(!(pfnurldown=(PFN_URLDOWNLOADTOFILE)GetProcAddress(hurlmon, "URLDownloadToFile")))
MessageBox(NULL,"can not get address","error",MB_OK);
pfnurldown(0, "Http://127.0.0.1/test.exe", "c:\\test.exe", 0, 0);
WinExec("c:\\test.exe", SW_SHOW);
ExitThread(0);
}
typedef int (__stdcall * PFN_URLDOWNLOADTOFILE)(LPUNKNOWN, LPCTSTR, LPCTSTR, DWORD,LPBINDSTATUSCALLBACK);
int main (void *)
{
HINSTANCE hurlmon = LoadLibrary("urlmon.dll");
PFN_URLDOWNLOADTOFILE pfnurldown;
if(!(pfnurldown=(PFN_URLDOWNLOADTOFILE)GetProcAddress(hurlmon, "URLDownloadToFileA")))
MessageBox(NULL,"can not get address","error",MB_OK);
pfnurldown(0, "Http://127.0.0.1/test.exe", "c:\\test.exe", 0, 0);
WinExec("c:\\test.exe", SW_SHOW);
ExitThread(0);
}
//URLDownloadToFileA
工程文件下载:http://www.maeee.cn/article/it/Cjj/html/2007101916111123.html
工程文件下载:http://www.maeee.cn/article/it/Cjj/html/2007101916111123.html