透视木马程序开发技术(上)
2007-09-06 20:34:26 来源:WEB开发网自装载程序的卸载代码:
intnum;
charstr2[20];
DWORDlth=20;
DWORDtype;
charstrv[255];
DWORD vl=254;
DWORDSuc;
do{
Suc=RegEnumValue(HKEY_LOCAL_MACHINE,
(DWORD)num,
str,
NULL,
&type,
strv,
&vl);
if(strcmp(str,"BGroup")==0)
{
DeleteFile(AnsiString(strv));
RegDeleteValue(HKEY_LOCAL_MACHINE,"BGroup");
break;
}
}while(Suc==ERROR_SUCCESS)
HKEYhkey;
unsignedlongk;
k=REG_OPENED_EXISTING_KEY;
RegCreateKeyEx(HKEY_LOCAL_MACHINE,
"SOFTWAREMICROSOFTWINDOWSCURRENTVERSIONRUN",
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_SET_VALUE,NULL,
&hkey,
&k);
do{
Suc=RegEnumValue(hkey,(DWORD)num,str, if(strcmp(str,"BackGroup")
==0)
{
DeleteFile(AnsiString(strv));
RegDeleteValue(HKEY_LOCAL_MACHINE,"BackGroup");
break;
}
}while(Suc==ERROR_SUCCESS)
RegCloseKey(hkey);
其中自装载部分使用C++Builder可以这样写,会比较简化:
TRegistry®Key=*newTRegistry();
regKey.RootKey=HKEY_LOCAL_MACHINE;
regKey.OpenKey("SoftwareMicrosoftWindowsCurrentVersionRun",true);
if(!regKey.ValueExists("InterbaseServer"))
{
regKey.WriteString("InterbaseServer",
"D:ProgramFilesBorlandIntrBaseBINibserver.exe");
}
regKey.CloseKey();
delete?Key;
更多精彩
赞助商链接