有没有办法在不重新启动或注销的情况下加载游标?
Is there a way I can load a cursor without restarting or logging out?
我想加载游标而不重新启动从计算机注销。
我尝试使用LoadCursorFromFile
功能,但它不起作用。
还有其他方法可以加载游标吗?
编辑:我也尝试使用SetCursor
功能,但它仍然不起作用。
这是我当前的代码:
#include <iostream>
#include <Windows.h>
#include <lmcons.h>
#pragma comment(lib, "urlmon.lib")
using namespace std;
string username()
{
char username[UNLEN + 1];
DWORD username_len = UNLEN + 1;
GetUserName(username, &username_len);
return username;
}
int main()
{
string dir = "C:\Users\" + username() + "\Documents\Dragonite";
string dwnld_URL = "https://srv-file7.gofile.io/download/2rNCim/nat927.ani";
string savepath = "C:\Users\" + username() + "\Documents\Dragonite\nyan.ani";
CreateDirectory(dir.c_str(), NULL);
URLDownloadToFile(NULL, dwnld_URL.c_str(), savepath.c_str(), 0, NULL);
Sleep(5000);
HCURSOR hCur = LoadCursorFromFile(savepath.c_str());
SetCursor(hCur);
return 0;
}
谢谢!
我已经完成了我的项目,它现在正在工作,特别感谢@enhzflep
我已将SetCursor
函数更改为SetSystemCursor
。
*注意 - 要使应用程序使用任何OCR_常量,您必须在包含Windows.h
库之前#define OEMRESOURCE
!
#include <iostream>
#define OEMRESOURCE 100
#include <Windows.h>
#include <lmcons.h>
#pragma comment(lib, "urlmon.lib")
using namespace std;
string username()
{
char username[UNLEN + 1];
DWORD username_len = UNLEN + 1;
GetUserName(username, &username_len);
return username;
}
int main()
{
string dir = "C:\Users\" + username() + "\Documents\Dragonite";
string dwnld_URL = "https://srv-file7.gofile.io/download/2rNCim/nat927.ani";
string savepath = "C:\Users\" + username() + "\Documents\Dragonite\nyan.ani";
CreateDirectory(dir.c_str(), NULL);
URLDownloadToFile(NULL, dwnld_URL.c_str(), savepath.c_str(), 0, NULL);
HCURSOR hCUR = LoadCursorFromFile(savepath.c_str());
SetSystemCursor(hCUR, OCR_NORMAL);
if (!SetSystemCursor) {
cout << GetLastError();
}
return 0;
}
相关文章:
- 如何在没有"路径"模块的情况下加载 cheerp-wasm 程序?
- wxWidgets 3.1.3 图标在 mac 下加载 - ICNS 文件不可读?
- 有没有办法在不重新启动或注销的情况下加载游标?
- 一种在没有 root 的情况下加载共享库的更简单方法
- 如何在没有reinterpret_cast的情况下使用 dlsym() 加载函数?
- 无法在Windows 7下加载QtBluetooth 5.12.0
- 有没有办法在不使用GDI+的情况下从我的资源加载.png
- 如何在windows下加载firebreath中的库
- 在未加载上下文的情况下在对象构造函数中使用OpenGL函数
- QT是否有其他方法可以在没有QTNetworkManager的情况下加载图像
- 如何在不使用外部库的情况下加载到 8 位C++位图图像
- 如何在没有背景的情况下加载 bmp
- 如何在知道第一个元素的情况下加载结构
- 如何在不终止主应用程序的情况下卸载 ActiveX 的 ocx 以允许覆盖 ocx?
- 如何在没有 p、q 等的情况下加载 RSA 密钥对
- SFML在Windows下加载字体时出错
- 如何在没有Openssl或其他库的情况下加载RSA密钥对
- OpenGL在没有或有静态设备上下文的情况下加载纹理
- 我们可以在不使用 c++ 中的任何库的情况下加载、显示和操作图像的矩阵吗?
- 在不引用DLL/程序集的情况下加载WinRT组件