关于注册mscomm程序的编写[2]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

   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;
}

 可执行文件:

本文关键:关于注册mscomm程序的编写
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top