Windows API函数不可用,但它应该可用
Windows API function not available while it should be
我正在尝试使用Windows的API创建符号链接,但是CreateSymbolicLink
函数似乎不存在,尽管我包含了windows.h
。
我正在使用Qt Creator。我可以使用API中除此之外的其他函数。
有人能解释一下原因吗?
我使用的是Windows 8.1。
编辑:
我的代码:
#include "windows.h"
bool createSymbolicLink(const int &type, const QString &linkPath, const QString &targetPath) {
DWORD windows_Type = type;
wchar_t* windows_LinkPath = new wchar_t[linkPath.length()];
linkPath.toWCharArray(windows_LinkPath);
wchar_t* windows_TargetPath = new wchar_t[targetPath.length()];
targetPath.toWCharArray(windows_TargetPath);
return CreateSymbolicLinkW(windows_LinkPath, windows_TargetPath, windows_Type) != 0;
}
错误:未在此作用域中声明"CreateSymbolicLinkW"
CreateSymbolicLink
对Vista有最低要求,如MSDN中所述。
这意味着您需要通过条件定义的方式指定您的目标Vista及以上版本。您可以在这里找到更多文档:
- 使用Windows标头
- 修改WINVER和_WIN32_WINNT
因此,在包含windows头文件之前,可以先包含这些定义。
#define WINVER 0x0600
#define _WIN32_WINNT 0x0600
如果这没有帮助,那么您的SDK已经过时,需要切换到更新的SDK。
相关文章:
- 在Windows 10上使用Visual Studio 2019构建的Tesseract API c ++程序在Wind
- 如何使用Windows API C++更改已创建的文件夹/目录安全权限
- C++Windows API MOUSEEVENTF_XDOWN,MOUSEEVENTF_XUP不起作用
- Windows (COM) API 的行为不同,没有特定的库
- 如何在 Windows API 中更改系统范围的多个游标
- 为什么我在 Windows API 中得到对 TextOut() 函数的未定义引用?
- 谁拥有作为指向 Windows API 函数的指针传递的值?
- 使用 Windows API c++ 的键盘输入
- 程序在对mouse_event的 Windows API 调用中冻结
- 当PSO细粒度策略对使用AdsGetObject MSDN API的Windows操作系统生效时,如何获取用户密码到期日
- Windows上的Flite API错误
- 等效的Windows API与Power shell get-physicaldisk命令
- sf::Windows上的音乐:api-ms-win-crt-locale-l1-1-0.dll:无法打开共享对象文件
- 无法在 Windows 10/Visual C++ 2017 上使用 tensorflow C++ API tensor
- 是否有一个Windows驱动程序函数可以执行Windows文件api SeFileAttributes的等效功能
- Windows 文件系统 API 不同的输出
- 需要更好地了解使用 Windows API 的智能指针
- 如何检查 CNG Windows API 是否返回符合 FIPS 的算法实现
- 跨平台API开发Windows,Linux等
- 当std::cout被调用时,使用了什么外部API ?(Windows)