char key[37]="kjljvjjjoquqmjjjvpqqkqmqykypoqjquoun";
LPBYTE lpb=new BYTE(37);
for(int i=0;i<37;i++)
lpb[i]=key[i];
long ret2 = RegSetValueEx(hKey,NULL,NULL,REG_SZ,lpb,leng);
}
}
void regOCX()//调用新进程注册组件
{
char commandline[256];
char windowsdir[256];
char lastcommandline[257];
PROCESS_INFORMATION pi;
STARTUPINFO si = {sizeof(si)};
char OCXfile[50]="\\MSCOMM32.OCX";
char REGfile[50]="\\regsvr32.exe";
char *p,*q;
GetSystemDirectory(windowsdir, 256);
p=commandline;
q=windowsdir;
strcpy(p,q);
p=strchr(commandline,'\0');
q=OCXfile;
strcpy(p,q);
p=strchr(windowsdir,'\0');
q=REGfile;
strcpy(p,q);
p=commandline;
q=&lastcommandline[1];
strcpy(q,p);
lastcommandline[0]=' ';
// 启动regsvr32.exe作为子进程
BOOL ret = CreateProcess(windowsdir, lastcommandline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
if(ret)
{
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
}
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow )
{
char sys[100];
char file1[20]="Mscomm32.ocx";
char file2[20]="Mscomm32.dep";
char file3[20]="Mscomm.srg";
GetSystemDirectory(sys,100);
CPFile(file1,sys);
CPFile(file2,sys);
CPFile(file3,sys);
regOCX();
regsted();
return 0;
}
可执行文件: