当前位置:编程学习 > 网站相关 >>

注册表操作(RingZ_RgeEdit)


 

代码:注册表操作(RingZ_RgeEdit) RingZ_CDUser的扩展版本
作者:dahubaobao
主页:http://www.ringz.org
邮件:dahushibaobao@vip.sina.com
QQ:382690
EXE在压缩包中,解压密码:www.ringz.org
http://dahubaobao.go.nease.net/RingZ_RgeEdit.rar
欢迎进入环形区,一群技术狂热者的社区,www.ringz.org欢迎你的加入!
注:转载请著名出处,谢谢!
=====================================================================
#include "Functions.h"

int main (int argc, char *argv[])
{
char SID[10],C_Sid[10],USER[20];
char *K_Sid="1F4";
char *K_User="Administrator";
int n;

for (n=1;n<argc;n++)
{
if (argv[n][0]==-||argv[n][0]==/)
{
switch(argv[n][1])
{
case ?:
case h:
case H:Usage();
break;

case l:
case L:ListUser();
break;

case f:
case F:Main_Correlation();
break;

case e:
case E:EX_Correlation();
break;

case c:
case C:printf("Please Input Clone SID:");
gets(C_Sid);
if (strlen(C_Sid)<=10&&strcmp(C_Sid,K_Sid)!=0)
Clone(C_Sid);
else
{
printf("Error ");
exit(0);
}
break;

case s:
case S:printf("Please Input Delete SID:");
gets(SID);
if (strlen(SID)<=10&&strcmp(SID,K_Sid)!=0)
Sid(SID);
else
{
printf("Error ");
exit(0);
}
break;

case u:
case U:printf("Please Input Delete USER:");
gets(USER);
if (strlen(USER)<=20&&strcmp(USER,K_User)!=0)
User(USER);
else
{
printf("Error ");
exit(0);
}
break;

default:Usage();
}
}
}
return 0;
}

int Main_Correlation (void)
{
int r_count;

C_Usage();
r_count=Correlation();

while (r_count!=EXIT)
{
C_Usage();
r_count=Correlation();
}
printf("File Correlation End ");
return 0;
}

int Correlation (void)
{
char TXT_file[50],EXE_file[50],HLP_file[50],INF_file[50],INI_file[50];
char E_Key[20],Key[20],D_Value[20],Value[50];
int count;

while (scanf("%d",&count)==1)
{
if (count==LOW||count>EXIT)
{
C_Usage();
continue;
}

if (count==EXIT)
{
printf("ByeBye! ");
break;
}

while (getchar()!= )
continue;

switch(count)
{
case 1:printf("Correlation TXT:");
gets(TXT_file);
if (strlen(TXT_file)<=50)
TXT_Correlation(TXT_file);
else
{
printf("Error ");
exit(0);
}
break;

case 2:printf("Correlation EXE:");
gets(EXE_file);
if (strlen(EXE_file)<=50)
EXE_Correlation(EXE_file);
else
{
printf("Error ");
exit(0);
}
break;

case 3:printf("Correlation HLP:");
gets(HLP_file);
if (strlen(HLP_file)<=50)
HLP_Correlation(HLP_file);
else
{
printf("Error ");
exit(0);
}
break;

case 4:printf("Correlation INF:");
gets(INF_file);
if (strlen(INF_file)<=50)
INF_Correlation(INF_file);
else
{
printf("Error ");
exit(0);
}
break;

case 5:printf("Correlation INI:");
gets(INI_file);
if (strlen(INI_file)<=50)
INI_Correlation(INI_file);
else
{
printf("Error ");
exit(0);
}
break;

case 6:printf("Setting Correlation ");
printf("Please Input E_KeyName(E_Key):");
if (!(strlen(gets(E_Key))<=20))
{
printf("Error ");
exit(0);
}
printf("Please Input KeyName(Key):");
if (!(strlen(gets(Key))<=20))
{
printf("Error ");
exit(0);
}
printf("Please Input D_KeyValue(D_Value):");
if (!(strlen(gets(D_Value))<=20))
{
printf("Error ");
exit(0);
}
printf("Please Input KeyValue(Value):");
if (strlen(gets(Value))<=50)
DIY_Correlation(E_Key,Key,D_Value,Value);
else
{
printf("Error ");
exit(0);
}
}

}

while (getchar()!= )
continue;
return count;
}

void TXT_Correlation (char *TXTFile)
{
HKEY hkey;
DWORD szData=100,ret=0;
char *key="txtfile\shell\open\command\";

ret=RegCreateKey(HKEY_CLASSES_ROOT,key,&hkey);
//在指定的项下创建一个新项。如指定的项已经存在,那么函数会打开现有的项
//hKey Long,要打开项的句柄,或者一个标准项名
//lpSubKey String,欲创建的新子项。可同时创建多个项,只需用反斜杠将它们分隔开即可。
//例如level1level2 ewkey。如果指定"",则为默认值。
//phkResult Long,指定一个变量,用于装载新子项的句柄

if (!ret==ERROR_SUCCESS)
{
printf("Reg Create FAIL ");
exit(0);
}

ret=RegSetValueEx(hkey,"",0,REG_EXPAND_SZ,TXTFile,szData);

if (ret==ERROR_SUCCESS)
printf("TXT_File Correlation Success ");
else
{
printf("TXT_File Correlation FAIL ");
exit(0);
}

RegCloseKey(hkey);
}

void EXE_Correlation (char *EXEFile)
{
HKEY hkey;
DWORD szData=100,ret=0;
char *key="exefile\shell\open\command\";

ret=RegCreateKey(HKEY_CLASSES_ROOT,key,&hkey);

if (!ret==ERROR_SUCCESS)
{
printf("Reg Create FAIL ");
exit(0);
}

ret=RegSetValueEx(hkey,"",0,REG_SZ,EXEFile,szData);

if (ret==ERROR_SUCCESS)
printf("EXE_File Correlation Success ");
else
{
printf("EXE_File Correlation FAIL ");
exit(0);
}

RegCloseKey(hkey);
}

void INF_Correlation (char *INFFile)
{
HKEY hkey;
DWORD szData=100,ret=0;
char *key="inffile\shell\open\command\";

ret=RegCreateKey(HKEY_CLASSES_ROOT,key,&hkey);

if (!ret==ERROR_SUCCESS)
{
printf("Reg Create FAIL ");
exit(0);
}

ret=RegSetValueEx(hkey,"",0,REG_EXPAND_SZ,INFFile,szData);

if (ret==ERROR_SUCCESS)
printf("INF_File Correlation Success ");
else
{
printf("INF_File Correlation FAIL ");
exit(0);
}

RegCloseKey(hkey);
}

void INI_Correlation (char *INIFile)
{
HKEY hkey;
DWORD szData=100,ret=0;
char *key="inifile\shell\open\command\";

ret=RegCreateKey(HKEY_CLASSES_ROOT,key,&hkey);

if (!ret==ERROR_SUCCESS)
{
printf("Reg Create FAIL ");
exit(0);
}

ret=RegSetValueEx(hkey,"",0,REG_EXPAND_SZ,INIFile,szData);

if (ret==ERROR_SUCCESS)
printf("INI_File Correlation Success ");
else
{
printf("INI_File Correlation FAIL ");
exit(0);
}

RegCloseKey(hkey);
}

void HLP_Correlation (char *HLPFile)
{
HKEY hkey;
DWORD szData=100,ret=0;
char *key="helpfile\shell\open\command\";

ret=RegCreateKey(HKEY_CLASSES_ROOT,key,&hkey);

if (!ret==ERROR_SUCCESS)
{
printf("Reg Create FAIL ");
exit(0);
}

ret=RegSetValueEx(hkey,"",0,REG_SZ,HLPFile,szData);

if (ret==ERROR_SUCCESS)
printf("HLP_File Correlation Success ");
else
{
printf("HLP_File Correlation FAIL ");
exit(0);
}

RegCloseKey(hkey);
}

int DIY_Correlation(
char *E_KeyName,char *KeyName,char *D_KeyValue,char *KeyValue)
{
HKEY hkey;
DWORD szData=100,ret=0;
char Key[50];
ZeroMemory(Key,50);

ret=RegCreateKey(HKEY_CLASSES_ROOT,E_KeyName,&hkey);

if (!ret==ERROR_SUCCESS)
{
printf("One:Reg Create FAIL ");
exit(0);
}

ret=RegSetValueEx(hkey,"",0,REG_SZ,KeyName,szData);

if (ret==ERROR_SUCCESS)
printf("One:Setting RegKey Success ");
else
{
printf("One:Setting RegKey FAIL ");
exit(0);
}

ret=RegCreateKey(HKEY_CLASSES_ROOT,KeyName,&hkey);

if (!ret==ERROR_SUCCESS)
{
printf("Two:Reg Create FAIL ");
exit(0);
}

ret=RegSetValueEx(hkey,"",0,REG_SZ,D_KeyValue,szData);

if (ret==ERROR_SUCCESS)
printf("Two:Setting RegKeyValue Success ");
else
{
pr

补充:综合编程 , 安全编程 ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,