4 typedef struct _LANGCODEPAGE
8 } LANGCODEPAGE
, *PLANGCODEPAGE
;
11 IsSameObject(IN IUnknown
*punk1
, IN IUnknown
*punk2
)
15 hRet
= punk1
->QueryInterface(IID_PPV_ARG(IUnknown
, &punk1
));
20 hRet
= punk2
->QueryInterface(IID_PPV_ARG(IUnknown
, &punk2
));
29 /* We're dealing with the same object if the IUnknown pointers are equal */
30 return (punk1
== punk2
) ? S_OK
: S_FALSE
;
34 SetWindowStyle(IN HWND hWnd
,
38 LONG PrevStyle
, Style
;
40 ASSERT((~dwStyleMask
& dwStyle
) == 0);
42 PrevStyle
= GetWindowLong(hWnd
, GWL_STYLE
);
44 (PrevStyle
& dwStyleMask
) != dwStyle
)
46 Style
= PrevStyle
& ~dwStyleMask
;
49 PrevStyle
= SetWindowLong(hWnd
, GWL_STYLE
, Style
);
56 SetWindowExStyle(IN HWND hWnd
,
60 LONG PrevStyle
, Style
;
62 ASSERT((~dwStyleMask
& dwStyle
) == 0);
64 PrevStyle
= GetWindowLong(hWnd
, GWL_EXSTYLE
);
66 (PrevStyle
& dwStyleMask
) != dwStyle
)
68 Style
= PrevStyle
& ~dwStyleMask
;
71 PrevStyle
= SetWindowLong(hWnd
, GWL_EXSTYLE
, Style
);
78 LoadPopupMenu(IN HINSTANCE hInstance
,
79 IN LPCTSTR lpMenuName
)
81 HMENU hMenu
, hSubMenu
= NULL
;
83 hMenu
= LoadMenu(hInstance
,
88 hSubMenu
= GetSubMenu(hMenu
,
90 if (hSubMenu
!= NULL
&&
105 FindSubMenu(IN HMENU hMenu
,
111 mii
.cbSize
= sizeof(mii
);
112 mii
.fMask
= MIIM_SUBMENU
;
114 if (GetMenuItemInfo(hMenu
,
126 GetCurrentLoggedOnUserName(OUT LPTSTR szBuffer
,
127 IN DWORD dwBufferSize
)
132 /* Query the user name from the registry */
133 dwSize
= (dwBufferSize
* sizeof(WCHAR
)) - 1;
134 if (RegQueryValueEx(hkExplorer
,
135 TEXT("Logon User Name"),
139 &dwSize
) == ERROR_SUCCESS
&&
140 (dwSize
/ sizeof(WCHAR
)) > 1 &&
141 szBuffer
[0] != _T('\0'))
143 szBuffer
[dwSize
/ sizeof(WCHAR
)] = _T('\0');
147 /* Fall back to GetUserName() */
148 dwSize
= dwBufferSize
;
149 if (!GetUserName(szBuffer
,
152 szBuffer
[0] = _T('\0');
160 FormatMenuString(IN HMENU hMenu
,
170 /* Find the menu item and read the formatting string */
171 mii
.cbSize
= sizeof(mii
);
172 mii
.fMask
= MIIM_STRING
;
173 mii
.dwTypeData
= (LPTSTR
) szBufFmt
;
174 mii
.cch
= sizeof(szBufFmt
) / sizeof(szBufFmt
[0]);
175 if (GetMenuItemInfo(hMenu
,
180 /* Format the string */
181 va_start(vl
, uFlags
);
183 (sizeof(szBuf
) / sizeof(szBuf
[0])) - 1,
187 szBuf
[(sizeof(szBuf
) / sizeof(szBuf
[0])) - 1] = _T('\0');
189 /* Update the menu item */
190 mii
.dwTypeData
= (LPTSTR
) szBuf
;
191 if (SetMenuItemInfo(hMenu
,
204 GetExplorerRegValueSet(IN HKEY hKey
,
208 WCHAR szBuffer
[MAX_PATH
];
210 DWORD dwType
, dwSize
;
213 StringCbCopy(szBuffer
, sizeof(szBuffer
),
214 TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer"));
215 if (FAILED_UNEXPECTEDLY(StringCbCat(szBuffer
, sizeof(szBuffer
),
218 if (FAILED_UNEXPECTEDLY(StringCbCat(szBuffer
, sizeof(szBuffer
),
222 dwSize
= sizeof(szBuffer
);
223 if (RegOpenKeyEx(hKey
,
227 &hkSubKey
) == ERROR_SUCCESS
)
232 if (RegQueryValueEx(hkSubKey
,
237 &dwSize
) == ERROR_SUCCESS
)
239 if (dwType
== REG_DWORD
&& dwSize
== sizeof(DWORD
))
240 Ret
= *((PDWORD
) szBuffer
) != 0;
242 Ret
= *((PCHAR
) szBuffer
) != 0;
245 RegCloseKey(hkSubKey
);
251 GetVersionInfoString(IN WCHAR
*szFileName
,
252 IN WCHAR
*szVersionInfo
,
256 LPVOID lpData
= NULL
;
257 WCHAR szSubBlock
[128];
258 WCHAR
*lpszLocalBuf
= NULL
;
260 PLANGCODEPAGE lpTranslate
= NULL
;
268 dwLen
= GetFileVersionInfoSize(szFileName
, &dwHandle
);
272 lpData
= HeapAlloc(hProcessHeap
, 0, dwLen
);
276 if (GetFileVersionInfo(szFileName
,
281 UserLangId
= GetUserDefaultLangID();
283 VerQueryValue(lpData
,
284 TEXT("\\VarFileInfo\\Translation"),
285 (LPVOID
*) &lpTranslate
,
288 for (i
= 0; i
< cbTranslate
/ sizeof(LANGCODEPAGE
); i
++)
290 /* If the bottom eight bits of the language id's
291 match, use this version information (since this
292 means that the version information and the users
293 default language are the same). */
294 if ((lpTranslate
[i
].wLanguage
& 0xFF) ==
297 wnsprintf(szSubBlock
,
298 sizeof(szSubBlock
) / sizeof(szSubBlock
[0]),
299 TEXT("\\StringFileInfo\\%04X%04X\\%s"),
300 lpTranslate
[i
].wLanguage
,
301 lpTranslate
[i
].wCodePage
,
304 if (VerQueryValue(lpData
,
306 (LPVOID
*) &lpszLocalBuf
,
309 _tcsncpy(szBuffer
, lpszLocalBuf
, cbBufLen
/ sizeof(*szBuffer
));
317 HeapFree(hProcessHeap
, 0, lpData
);