Advertisement
Guest User

Untitled

a guest
Sep 21st, 2011
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. /*
  2. ///////////////////////////////////////
  3. MouseShadowFix by vebero v1.0
  4. ///////////////////////////////////////
  5. */
  6.  
  7. #define WIN32_LEAN_AND_MEAN
  8.  
  9. #include <Windows.h>
  10.  
  11. #pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
  12.  
  13. typedef __int32 int32;
  14.  
  15. typedef unsigned __int32 uint32;
  16.  
  17. #define MSGBOX_ERROR MB_ICONERROR | MB_OK
  18.  
  19. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  20. {
  21. int32 nResult;
  22.  
  23. HKEY hKey = nullptr;
  24.  
  25. nResult = RegOpenKeyEx(HKEY_CURRENT_USER,
  26. L"Control Panel\\Desktop",
  27. 0,
  28. KEY_NOTIFY,
  29. &hKey);
  30.  
  31. if(nResult != ERROR_SUCCESS)
  32. MessageBox(nullptr, L"RegOpenKeyEx failed.", L"MouseShadowFix", MSGBOX_ERROR);
  33.  
  34. HANDLE hEvent = CreateEvent(nullptr, false, false, nullptr);
  35.  
  36. if(!hEvent)
  37. MessageBox(nullptr, L"CreateEvent failed.", L"MouseShadowFix", MSGBOX_ERROR);
  38.  
  39. while(true)
  40. {
  41. uint32 unFilter = REG_NOTIFY_CHANGE_LAST_SET;
  42.  
  43. nResult = RegNotifyChangeKeyValue(hKey,
  44. false,
  45. unFilter,
  46. hEvent,
  47. true);
  48.  
  49. if(nResult != ERROR_SUCCESS)
  50. MessageBox(nullptr, L"RegNotifyChangeKeyValue failed.", L"MouseShadowFix", MSGBOX_ERROR);
  51.  
  52. if(WaitForSingleObject(hEvent, INFINITE) == WAIT_OBJECT_0)
  53. {
  54. bool bShadowEnabled;
  55.  
  56. BOOL bResult = SystemParametersInfo(SPI_GETCURSORSHADOW,
  57. 0,
  58. &bShadowEnabled,
  59. 0);
  60.  
  61. if(!bResult)
  62. MessageBox(nullptr, L"SystemParametersInfo (GET) failed.", L"MouseShadowFix", MSGBOX_ERROR);
  63.  
  64. if(!bShadowEnabled)
  65. {
  66. bool bCursorShadow = true;
  67.  
  68. uint32 unChangeAction = SPIF_UPDATEINIFILE | SPIF_SENDCHANGE;
  69.  
  70. BOOL bResult = SystemParametersInfo(SPI_SETCURSORSHADOW,
  71. 0,
  72. &bCursorShadow,
  73. unChangeAction);
  74.  
  75. if(!bResult)
  76. MessageBox(nullptr, L"SystemParametersInfo (SET) failed.", L"MouseShadowFix", MSGBOX_ERROR);
  77. }
  78. }
  79. }
  80.  
  81. CloseHandle(hEvent);
  82.  
  83. RegCloseKey(hKey);
  84.  
  85. return 0;
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement