---------------------------------------------------------------------------
| 1254 | |
| 1255 | //--------------------------------------------------------------------------- |
| 1256 | int ExplorerShell_Edit(const AnsiString &Player, bool ShellExtension, bool &IsChanged) |
| 1257 | { |
| 1258 | ::HKEY Key; |
| 1259 | LONG WINAPI Result; |
| 1260 | Result=RegOpenKeyEx(HKEY_CURRENT_USER, Ztring().From_Local((Player+"\\Shell\\MediaInfo\\Command").c_str()).c_str(), 0, KEY_READ|KEY_WRITE, &Key); |
| 1261 | if (Result!=ERROR_SUCCESS && Result!=2) //2=not found |
| 1262 | { |
| 1263 | char lpMsgBuf[1000]; |
| 1264 | FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, Result, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), lpMsgBuf, 1000, NULL); |
| 1265 | return 0; |
| 1266 | } |
| 1267 | |
| 1268 | if (Result==ERROR_SUCCESS) |
| 1269 | { |
| 1270 | //MediaInfo shell extension is known |
| 1271 | if (ShellExtension) |
| 1272 | { |
| 1273 | //test if good writing |
| 1274 | Ztring ShellExtensionToWrite=__T("\"") + Ztring(Application->ExeName.c_str()) +__T("\" \"%1\""); |
| 1275 | DWORD ShellExtension_Size=65536; |
| 1276 | ZenLib::Char ShellExtension_Chars[65536]; |
| 1277 | Result=RegQueryValueEx(Key, NULL, 0, NULL, (LPBYTE)&ShellExtension_Chars, &ShellExtension_Size); |
| 1278 | if (Result!=ERROR_SUCCESS) |
| 1279 | { |
| 1280 | char lpMsgBuf[1000]; |
| 1281 | FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, Result, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), lpMsgBuf, 1000, NULL); |
| 1282 | RegCloseKey(Key); |
| 1283 | return 0; |
| 1284 | } |
| 1285 | if (ShellExtensionToWrite!=ShellExtension_Chars) |
| 1286 | { |
| 1287 | //This is not the good shell extension, writing new one |
| 1288 | Result=RegSetValueEx(Key, NULL, 0, REG_SZ, (LPBYTE)ShellExtensionToWrite.c_str(), (ShellExtensionToWrite.size()+1)*sizeof(ZenLib::Char)); |
| 1289 | if (Result!=ERROR_SUCCESS) |
| 1290 | { |
| 1291 | RegCloseKey(Key); |
| 1292 | return 0; |
| 1293 | } |
| 1294 | IsChanged=true; |
| 1295 | } |
| 1296 | RegCloseKey(Key); |
| 1297 | } |
| 1298 | else// if (Player!=__T("Folder")) |
| 1299 | { |
| 1300 | //Should not be here, deleting |
| 1301 | RegCloseKey(Key); |
| 1302 | Result=RegDeleteKey(HKEY_CURRENT_USER, Ztring().From_Local((Player+"\\Shell\\MediaInfo\\Command").c_str()).c_str()); |
| 1303 | if (Result!=ERROR_SUCCESS) |
| 1304 | { |
| 1305 | char lpMsgBuf[1000]; |
| 1306 | FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, Result, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), lpMsgBuf, 1000, NULL); |
| 1307 | return 0; |
| 1308 | } |
| 1309 | Result=RegDeleteKey(HKEY_CURRENT_USER, Ztring().From_Local((Player+"\\Shell\\MediaInfo").c_str()).c_str()); |
| 1310 | if (Result!=ERROR_SUCCESS) |
| 1311 | { |
| 1312 | char lpMsgBuf[1000]; |
| 1313 | FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, Result, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), lpMsgBuf, 1000, NULL); |