Changeset 23053 in vbox
- Timestamp:
- Sep 16, 2009 8:42:56 AM (15 years ago)
- Location:
- trunk/src/VBox/Additions/WINNT/VBoxTray
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/Makefile.kmk
r15176 r23053 41 41 helpers.cpp \ 42 42 VBoxTray.rc 43 ifdef VBOX_WITH_GUEST_PROPS 44 VBoxTray_DEFS += _WIN32_IE=0x500 VBOX_WITH_GUEST_PROPS 45 VBoxTray_SOURCES += \ 46 VBoxHostVersion.cpp 47 endif 48 43 49 VBoxTray_LIBS = \ 44 50 $(VBOX_LIB_IPRT_GUEST_R3) \ -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.cpp
r21905 r23053 27 27 #include "VBoxStatistics.h" 28 28 #include "VBoxMemBalloon.h" 29 #include "VBoxHostVersion.h" 29 30 #include <VBoxHook.h> 30 31 #include "resource.h" … … 299 300 Log(("VBoxTray: Window Handle = %p, Status = %p\n", gToolWindow, status)); 300 301 302 OSVERSIONINFO info; 303 DWORD dwMajorVersion = 5; /* default XP */ 304 info.dwOSVersionInfoSize = sizeof(info); 305 if (GetVersionEx(&info)) 306 { 307 Log(("VBoxTray: Windows version major %d minor %d\n", info.dwMajorVersion, info.dwMinorVersion)); 308 dwMajorVersion = info.dwMajorVersion; 309 } 310 301 311 if (status == NO_ERROR) 302 312 { … … 310 320 /* We need to setup a security descriptor to allow other processes modify access to the seamless notification event semaphore */ 311 321 SECURITY_ATTRIBUTES SecAttr; 312 OSVERSIONINFO info;313 322 char secDesc[SECURITY_DESCRIPTOR_MIN_LENGTH]; 314 DWORD dwMajorVersion = 5; /* default XP */315 323 BOOL ret; 316 324 … … 323 331 Log(("VBoxTray: SetSecurityDescriptorDacl failed with %d\n", GetLastError())); 324 332 325 info.dwOSVersionInfoSize = sizeof(info);326 if (GetVersionEx(&info))327 {328 Log(("VBoxTray: Windows version major %d minor %d\n", info.dwMajorVersion, info.dwMinorVersion));329 dwMajorVersion = info.dwMajorVersion;330 }331 332 333 /* For Vista and up we need to change the integrity of the security descriptor too */ 333 334 if (dwMajorVersion >= 6) … … 407 408 ndata.cbSize = NOTIFYICONDATA_V1_SIZE; // sizeof(NOTIFYICONDATA); 408 409 ndata.hWnd = gToolWindow; 409 ndata.uID = 2000;410 ndata.uID = ID_TRAYICON; 410 411 ndata.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; 411 412 ndata.uCallbackMessage = WM_USER; 412 413 ndata.hIcon = LoadIcon(gInstance, MAKEINTRESOURCE(IDI_VIRTUALBOX)); 413 414 sprintf(ndata.szTip, "Sun VirtualBox Guest Additions %d.%d.%dr%d", VBOX_VERSION_MAJOR, VBOX_VERSION_MINOR, VBOX_VERSION_BUILD, VBOX_SVN_REV); 414 415 415 Log(("VBoxTray: ndata.hWnd %08X, ndata.hIcon = %p\n", ndata.hWnd, ndata.hIcon)); 416 416 … … 472 472 fTrayIconCreated = Shell_NotifyIcon(NIM_ADD, &ndata); 473 473 Log(("VBoxTray: fTrayIconCreated = %d, err %08X\n", fTrayIconCreated, GetLastError ())); 474 475 /* We're ready to create the tooltip balloon. */ 476 if (fTrayIconCreated && dwMajorVersion >= 5) 477 { 478 /* Check in 10 seconds (@todo make seconds configurable) ... */ 479 SetTimer(gToolWindow, 480 WM_VBOX_CHECK_HOSTVERSION, 481 10000, /* 10 seconds */ 482 NULL /* no timerproc */); 483 } 474 484 } 475 485 } … … 508 518 { 509 519 /* Do not use a global namespace ("Global\\") for mutex name here, will blow up NT4 compatibility! */ 510 HANDLE hMutexAppRunning = CreateMutex 520 HANDLE hMutexAppRunning = CreateMutex(NULL, FALSE, "VBoxTray"); 511 521 if ( (hMutexAppRunning != NULL) 512 522 && (GetLastError() == ERROR_ALREADY_EXISTS)) … … 535 545 /* Release instance mutex. */ 536 546 if (hMutexAppRunning != NULL) { 537 CloseHandle 547 CloseHandle(hMutexAppRunning); 538 548 hMutexAppRunning = NULL; 539 549 } … … 554 564 555 565 case WM_DESTROY: 566 KillTimer(gToolWindow, WM_VBOX_CHECK_HOSTVERSION); 567 break; 568 569 case WM_TIMER: 570 571 switch (wParam) 572 { 573 case WM_VBOX_CHECK_HOSTVERSION: 574 if (RT_SUCCESS(VBoxCheckHostVersion())) 575 { 576 /* After successful run we don't need to check again. */ 577 KillTimer(gToolWindow, WM_VBOX_CHECK_HOSTVERSION); 578 } 579 return 0; 580 581 default: 582 break; 583 } 584 556 585 break; 557 586 -
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxTray.h
r21888 r23053 37 37 #include <VBox/VBoxGuestLib.h> 38 38 39 #define WM_VBOX_RESTORED 0x2005 40 #define WM_VBOX_CHECK_VRDP 0x2006 39 #define WM_VBOX_RESTORED WM_APP + 1 40 #define WM_VBOX_CHECK_VRDP WM_APP + 2 41 #define WM_VBOX_CHECK_HOSTVERSION WM_APP + 3 42 43 #define ID_TRAYICON 2000 41 44 42 45 … … 65 68 66 69 67 extern HWND gToolWindow; 70 extern HWND gToolWindow; 71 extern HINSTANCE gInstance; 68 72 69 73 extern void VBoxServiceReloadCursor(void); -
trunk/src/VBox/Additions/WINNT/VBoxTray/helpers.cpp
r8155 r23053 22 22 #include <windows.h> 23 23 24 #include <iprt/string.h> 25 #include <VBox/VBoxGuestLib.h> 26 27 #include <VBoxGuestInternal.h> 28 24 29 #include "helpers.h" 30 #include "resource.h" 25 31 26 32 static unsigned nextAdjacentRectXP (RECTL *paRects, unsigned nRects, unsigned iRect) … … 82 88 paNewRects[iResized].right += NewWidth - (paNewRects[iResized].right - paNewRects[iResized].left); 83 89 paNewRects[iResized].bottom += NewHeight - (paNewRects[iResized].bottom - paNewRects[iResized].top); 84 85 /* Verify all pairs of originally adjacent rectangles for all 4 directions. 90 91 /* Verify all pairs of originally adjacent rectangles for all 4 directions. 86 92 * If the pair has a "good" delta (that is the first rectangle intersects the second) 87 93 * at a direction and the second rectangle is not primary one (which can not be moved), 88 94 * move the second rectangle to make it adjacent to the first one. 89 95 */ 90 96 91 97 /* X positive. */ 92 98 unsigned iRect; … … 96 102 unsigned iNextRect = nextAdjacentRectXP (paRects, nRects, iRect); 97 103 DDCLOG(("next %d -> %d\n", iRect, iNextRect)); 98 104 99 105 if (iNextRect == ~0 || iNextRect == iPrimary) 100 106 { 101 107 continue; 102 108 } 103 109 104 110 /* Check whether there is an X intesection between these adjacent rects in the new rectangles 105 111 * and fix the intersection if delta is "good". 106 112 */ 107 113 int delta = paNewRects[iRect].right - paNewRects[iNextRect].left; 108 114 109 115 if (delta > 0) 110 116 { … … 112 118 paNewRects[iRect].right, paNewRects[iNextRect].left, 113 119 delta)); 114 120 115 121 paNewRects[iNextRect].left += delta; 116 122 paNewRects[iNextRect].right += delta; 117 123 } 118 124 } 119 125 120 126 /* X negative. */ 121 127 for (iRect = 0; iRect < nRects; iRect++) … … 124 130 unsigned iNextRect = nextAdjacentRectXN (paRects, nRects, iRect); 125 131 DDCLOG(("next %d -> %d\n", iRect, iNextRect)); 126 132 127 133 if (iNextRect == ~0 || iNextRect == iPrimary) 128 134 { 129 135 continue; 130 136 } 131 137 132 138 /* Check whether there is an X intesection between these adjacent rects in the new rectangles 133 139 * and fix the intersection if delta is "good". 134 140 */ 135 141 int delta = paNewRects[iRect].left - paNewRects[iNextRect].right; 136 142 137 143 if (delta < 0) 138 144 { … … 140 146 paNewRects[iRect].left, paNewRects[iNextRect].right, 141 147 delta)); 142 148 143 149 paNewRects[iNextRect].left += delta; 144 150 paNewRects[iNextRect].right += delta; 145 151 } 146 152 } 147 153 148 154 /* Y positive (in the computer sence, top->down). */ 149 155 for (iRect = 0; iRect < nRects; iRect++) … … 152 158 unsigned iNextRect = nextAdjacentRectYP (paRects, nRects, iRect); 153 159 DDCLOG(("next %d -> %d\n", iRect, iNextRect)); 154 160 155 161 if (iNextRect == ~0 || iNextRect == iPrimary) 156 162 { 157 163 continue; 158 164 } 159 165 160 166 /* Check whether there is an Y intesection between these adjacent rects in the new rectangles 161 167 * and fix the intersection if delta is "good". 162 168 */ 163 169 int delta = paNewRects[iRect].bottom - paNewRects[iNextRect].top; 164 170 165 171 if (delta > 0) 166 172 { … … 168 174 paNewRects[iRect].bottom, paNewRects[iNextRect].top, 169 175 delta)); 170 176 171 177 paNewRects[iNextRect].top += delta; 172 178 paNewRects[iNextRect].bottom += delta; 173 179 } 174 180 } 175 181 176 182 /* Y negative (in the computer sence, down->top). */ 177 183 for (iRect = 0; iRect < nRects; iRect++) … … 180 186 unsigned iNextRect = nextAdjacentRectYN (paRects, nRects, iRect); 181 187 DDCLOG(("next %d -> %d\n", iRect, iNextRect)); 182 188 183 189 if (iNextRect == ~0 || iNextRect == iPrimary) 184 190 { 185 191 continue; 186 192 } 187 193 188 194 /* Check whether there is an Y intesection between these adjacent rects in the new rectangles 189 195 * and fix the intersection if delta is "good". 190 196 */ 191 197 int delta = paNewRects[iRect].top - paNewRects[iNextRect].bottom; 192 198 193 199 if (delta < 0) 194 200 { … … 196 202 paNewRects[iRect].top, paNewRects[iNextRect].bottom, 197 203 delta)); 198 204 199 205 paNewRects[iNextRect].top += delta; 200 206 paNewRects[iNextRect].bottom += delta; 201 207 } 202 208 } 203 209 204 210 memcpy (paRects, paNewRects, sizeof (RECTL) * nRects); 205 211 return; 206 212 } 213 214 int showBalloonTip (HINSTANCE hInst, HWND hWnd, UINT uID, const char *pszMsg, const char *pszTitle, UINT uTimeout, DWORD dwInfoFlags) 215 { 216 NOTIFYICONDATA niData; 217 niData.cbSize = sizeof(NOTIFYICONDATA); 218 niData.uFlags = NIF_INFO; 219 niData.hWnd = hWnd; 220 niData.uID = uID; 221 niData.uTimeout = uTimeout; 222 if (dwInfoFlags == 0) 223 dwInfoFlags = NIIF_INFO; 224 niData.dwInfoFlags = dwInfoFlags; 225 226 OSVERSIONINFO info; 227 DWORD dwMajorVersion = 5; /* default XP */ 228 229 info.dwOSVersionInfoSize = sizeof(info); 230 if (FALSE == GetVersionEx(&info)) 231 return FALSE; 232 233 if (info.dwMajorVersion >= 5) 234 { 235 niData.uFlags |= NIF_ICON; 236 if ( info.dwMajorVersion == 5 237 && info.dwMinorVersion == 1) /* WinXP */ 238 { 239 //niData.dwInfoFlags = NIIF_USER; /* Use an own icon instead of the default one */ 240 niData.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_VIRTUALBOX)); 241 } 242 #ifdef BALLOON_WITH_VISTA_TOOLTIP_ICON 243 else if (info.dwMajorVersion == 6) /* Vista and up */ 244 { 245 niData.dwInfoFlags = NIIF_USER | NIIF_LARGE_ICON; /* Use an own icon instead of the default one */ 246 niData.hBalloonIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_VIRTUALBOX)); 247 } 248 #endif 249 } 250 251 strcpy(niData.szInfo, pszMsg ? pszMsg : ""); 252 strcpy(niData.szInfoTitle, pszTitle ? pszTitle : ""); 253 254 if (!Shell_NotifyIcon(NIM_MODIFY, &niData)) 255 return GetLastError(); 256 return 0; 257 } 258 259 /** @todo move this in guest lib, also used in a similar way in VBoxService */ 260 int getAdditionsVersion(char *pszVer, size_t cbSizeVer, char *pszRev, size_t cbSizeRev) 261 { 262 HKEY hKey; 263 int rc; 264 265 /* Check the new path first. */ 266 rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Sun\\VirtualBox Guest Additions", 0, KEY_READ, &hKey); 267 #ifdef RT_ARCH_AMD64 268 if (rc != ERROR_SUCCESS) 269 { 270 /* Check Wow6432Node (for new entries). */ 271 rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wow6432Node\\Sun\\VirtualBox Guest Additions", 0, KEY_READ, &hKey); 272 } 273 #endif 274 275 /* Still no luck? Then try the old xVM paths ... */ 276 if (RT_FAILURE(rc)) 277 { 278 rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Sun\\xVM VirtualBox Guest Additions", 0, KEY_READ, &hKey); 279 #ifdef RT_ARCH_AMD64 280 if (rc != ERROR_SUCCESS) 281 { 282 /* Check Wow6432Node (for new entries). */ 283 rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wow6432Node\\Sun\\xVM VirtualBox Guest Additions", 0, KEY_READ, &hKey); 284 } 285 #endif 286 } 287 288 /* Did we get something worth looking at? */ 289 if (RT_SUCCESS(rc)) 290 { 291 DWORD dwSize; 292 DWORD dwType; 293 294 /* Revision. */ 295 dwSize = cbSizeRev; 296 rc = RegQueryValueEx(hKey, "Revision", NULL, &dwType, (BYTE*)(LPCTSTR)pszRev, &dwSize); 297 /* Version. */ 298 dwSize = cbSizeVer; 299 rc = RegQueryValueEx(hKey, "Version", NULL, &dwType, (BYTE*)(LPCTSTR)pszVer, &dwSize); 300 } 301 302 if (NULL != hKey) 303 RegCloseKey(hKey); 304 305 return rc; 306 } -
trunk/src/VBox/Additions/WINNT/VBoxTray/helpers.h
r10800 r23053 32 32 33 33 void resizeRect(RECTL *paRects, unsigned nRects, unsigned iPrimary, unsigned iResized, int NewWidth, int NewHeight); 34 int showBalloonTip (HINSTANCE hInst, HWND hWnd, UINT uID, const char *pszMsg, const char *pszTitle, UINT uTimeout, DWORD dwInfoFlags); 35 int getAdditionsVersion(char *pszVer, size_t cbSizeVer, char *pszRev, size_t cbSizeRev); 34 36 35 37 #endif /* !___VBOXTRAY_HELPERS_H */
Note:
See TracChangeset
for help on using the changeset viewer.