c++ - 尝试 urldownloadtofile 函数时出错
问题描述
使用 urldownloadtofile 时出错,错误是:未定义对 `URLDownloadToFileA' 的引用
#include <iostream>
#include <Windows.h>
#include <string>
#pragma comment(lib, "urlmon.lib")
using namespace std;
int main()
{
string dwnld_URL = "http://www.412312myfuptoload.com/downloadpage/Honeygain.exe";
string savepath = "C:\\Users\\Ester\\Appdata\\Roaming\\Honeygain.exe";
URLDownloadToFile(NULL, dwnld_URL.c_str(), savepath.c_str(), 0, NULL);
return 0;
}
解决方案
#pragma comment(lib, "urlmon.lib")
与 MSVC(或兼容)编译器一起使用。
从错误和您之前的问题来看,您似乎正在使用 MinGW (ld 链接器),它不支持它。
因此,您应该链接该-lurlmon
选项。
推荐阅读
- amazon-ec2 - 没有特定标签的 ec2 启动的 Cloudwatch 警报
- python - 这个tic tac toe python游戏有什么问题
- sql - Postgresql - 将数字更改或反转为新列
- kubernetes - Kubernetes - cert-manager - 创建使用 Hashicorp Vault 的颁发者时出错
- .net - VB .net 在调试时更改代码将变量设置为空
- python - 我无法用 scrapy 提取此网址
- git - 如何创建 Fastlane Action 以返回过滤后的 git 提交
- solr - 在 Solr 中上传带有字段的文件
- python - 用于自动化功能的 .py 脚本
- yocto - 启动wifi接口时出错:无法加载regulatory.db