Доброго Всем времени суток.
Есть такая проблема: нужно из моего приложения запустить редактор реестра, но так чтобы он открылся на нужной мне ветке.(Как например в проге RegMonitor).
С уважением, Zlobni Virus.
ZV>Есть такая проблема: нужно из моего приложения запустить редактор реестра, но так чтобы он открылся на нужной мне ветке.(Как например в проге RegMonitor).
Это умеет делать regmon, и к нему есть исходники.
Смотри на
Sysinternals.
Здравствуйте, Lopcom, Вы писали:
ZV>>Есть такая проблема: нужно из моего приложения запустить редактор реестра, но так чтобы он открылся на нужной мне ветке.(Как например в проге RegMonitor).
L>Это умеет делать regmon, и к нему есть исходники.
L>Смотри на Sysinternals.
Весь сайт облазил, но исходников не нашел.Если не трудно пришли мне на мыло
Здравствуйте, zlobni-virus, Вы писали:
ZV>Здравствуйте, Lopcom, Вы писали:
ZV>>>Есть такая проблема: нужно из моего приложения запустить редактор реестра, но так чтобы он открылся на нужной мне ветке.(Как например в проге RegMonitor).
L>>Это умеет делать regmon, и к нему есть исходники.
L>>Смотри на Sysinternals.
ZV>Весь сайт облазил, но исходников не нашел.Если не трудно пришли мне на мыло
Там уже нет
Вот кусок кода от туда:
/******************************************************************************
*
* FUNCTION: RegeditJump
*
* PURPOSE: Opens Regedit and navigates the desired key
*
*****************************************************************************/
void RegeditJump( HWND hWnd )
{
int currentItem;
int pos;
char * ch;
HWND regeditHwnd, regeditMainHwnd;
char compressPath[MAX_PATH];
HKEY hKey;
char *value = NULL;
DWORD status;
char RegPath[MAX_PATH];
DEVMODE devMode;
// Get the color depth, which can effect the speed that Regedit
// responds to keyboard commands
devMode.dmSize = sizeof(DEVMODE);
EnumDisplaySettings( NULL, ENUM_CURRENT_SETTINGS, &devMode );
// See if we can get a Registry path out of the listview
// find the item with the focus
currentItem = ListView_GetNextItem( hWndList, -1, LVNI_SELECTED );
if( currentItem == -1 ) {
MessageBox( hWnd, "No item selected.", APPNAME, MB_OK|MB_ICONWARNING );
return;
}
memset( compressPath, 0, MAX_PATH );
ListView_GetItemText( hWndList, currentItem, 4, compressPath, MAX_PATH );
// If the key is a handle reference, tell the user we're sorry
if( compressPath[0] == '0' ) {
MessageBox( hWnd, "The full name of the selected key or value is not available.",
APPNAME, MB_OK|MB_ICONWARNING );
return;
}
// We need to uncompress abbreviations
if( !strncmp( compressPath, "HKLM", strlen("HKLM"))) {
sprintf( RegPath, "\\HKEY_LOCAL_MACHINE%s", &compressPath[strlen("HKLM")] );
status = RegOpenKey( HKEY_LOCAL_MACHINE, &compressPath[strlen("HKLM")+1], &hKey );
} else if( !strncmp( compressPath, "HKCU", strlen("HKCU"))) {
sprintf( RegPath, "\\HKEY_CURRENT_USER%s", &compressPath[strlen("HKCU")] );
status = RegOpenKey( HKEY_CURRENT_USER, &compressPath[strlen("HKCU")+1], &hKey );
} else if( !strncmp( compressPath, "HKCC", strlen("HKCC"))) {
sprintf( RegPath, "\\HKEY_CURRENT_CONFIG%s", &compressPath[strlen("HKCC")] );
status = RegOpenKey( HKEY_CURRENT_CONFIG, &compressPath[strlen("HKCC")+1], &hKey );
} else if( !strncmp( compressPath, "HKCR", strlen("HKCR"))) {
sprintf( RegPath, "\\HKEY_CLASSES_ROOT%s", &compressPath[strlen("HKCR")] );
status = RegOpenKey( HKEY_CLASSES_ROOT, &compressPath[strlen("HKCR")+1], &hKey );
} else if( !strncmp( compressPath, "HKU", strlen("HKU"))) {
sprintf( RegPath, "\\HKEY_USERS%s", &compressPath[strlen("HKU")] );
status = RegOpenKey( HKEY_USERS, &compressPath[strlen("HKU")+1], &hKey );
} else {
strcpy( RegPath, compressPath );
status = FALSE;
}
// Is it a value or a key?
if( status == ERROR_SUCCESS ) {
RegCloseKey( hKey );
strcat( RegPath, "\\" );
} else {
value = strrchr( RegPath, '\\')+1;
*strrchr( RegPath, '\\' ) = 0;
}
// Open RegEdit
regeditMainHwnd = FindWindow( "RegEdit_RegEdit", NULL );
if ( regeditMainHwnd == NULL ) {
SHELLEXECUTEINFO info;
memset( &info, 0, sizeof info );
info.cbSize = sizeof info;
info.fMask = SEE_MASK_NOCLOSEPROCESS;
info.lpVerb = "open";
info.lpFile = "regedit.exe";
info.nShow = SW_SHOWNORMAL;
ShellExecuteEx( &info );
WaitForInputIdle( info.hProcess, INFINITE );
regeditMainHwnd = FindWindow( "RegEdit_RegEdit", NULL );
}
if( regeditMainHwnd == NULL ) {
MessageBox( hWnd, "Regmon was unable to launch Regedit.",
APPNAME, MB_OK|MB_ICONERROR );
return;
}
ShowWindow( regeditMainHwnd, SW_SHOW );
SetForegroundWindow( regeditMainHwnd );
// Get treeview
regeditHwnd = FindWindowEx( regeditMainHwnd, NULL, "SysTreeView32", NULL );
SetForegroundWindow( regeditHwnd );
SetFocus( regeditHwnd );
// Close it up
for ( pos = 0; pos < 30; ++pos ) {
UINT vk = VK_LEFT;
SendMessage( regeditHwnd, WM_KEYDOWN, vk, 0 );
}
// wait for slow displays -
// Regedit takes a while to open keys with lots of subkeys
// when running at high color depths
if( devMode.dmBitsPerPel > 8 ) Sleep(REGEDITSLOWWAIT);
// Open path
for ( ch = RegPath; *ch; ++ch ) {
if ( *ch == '\\' ) {
UINT vk = VK_RIGHT;
SendMessage( regeditHwnd, WM_KEYDOWN, vk, 0 );
// wait for slow displays -
// Regedit takes a while to open keys with lots of subkeys
// when running at high color depths
if( devMode.dmBitsPerPel > 8 ) Sleep(REGEDITSLOWWAIT);
} else {
UINT vk = toupper(*ch);
SendMessage( regeditHwnd, WM_CHAR, vk, 0 );
}
}
// If its a value select the value
if( value ) {
UINT vk = VK_HOME;
regeditHwnd = FindWindowEx( regeditMainHwnd, NULL, "SysListView32", NULL );
SetForegroundWindow( regeditHwnd );
SetFocus( regeditHwnd );
Sleep(1000); // have to wait for Regedit to update listview
SendMessage( regeditHwnd, WM_KEYDOWN, vk, 0 );
for ( ch = value; *ch; ++ch ) {
UINT vk = toupper(*ch);
SendMessage( regeditHwnd, WM_CHAR, vk, 0 );
}
}
SetForegroundWindow( regeditMainHwnd );
SetFocus( regeditMainHwnd );
}
Правда, Ложь — мне все одно — я имею свое мнение.
Если функция недокументированна — это не значит, что ее не используют все ваши конкуренты в своих продуктах.
Любой строй переходный и отрицать это значит быть закостенелым идиотом.