.NET 2.0 检测

#include <stdio.h>
#include <stdlib.h>
#include<windows.h>

char GetSystemDisk(){
    char str[255];
    GetSystemDirectory(str, 255);
    return str[0];
}
char* merge(char *s1,char *s2,char* des){
    int length1=strlen(s1);
    int length2=strlen(s2);
    int sumLength=length1+length2;
    des=(char *)malloc(sizeof(char)*sumLength+1);
    int i=0;
    for(;i<sumLength;i++){
        if(i<=length1-1)
            des[i]=s1[i];
        else
            des[i]=s2[i-length1];
    }
    des[i]='\0';
    return des;
}
void strrpl(char* pDstOut, char* pSrcIn, const char* pSrcRpl, const char* pDstRpl)
{
char* pi = pSrcIn;
char* po = pDstOut;

int nSrcRplLen = strlen(pSrcRpl);
int nDstRplLen = strlen(pDstRpl);

char *p = NULL;
int nLen = 0;

do
{
// 找到下一个替换点
p = strstr(pi, pSrcRpl);

if(p != NULL)
{
// 拷贝上一个替换点和下一个替换点中间的字符串
nLen = p - pi;
memcpy(po, pi, nLen);

// 拷贝需要替换的字符串
memcpy(po + nLen, pDstRpl, nDstRplLen);
}
else
{
strcpy(po, pi);

// 如果没有需要拷贝的字符串,说明循环应该结束
break;
}

pi = p + nSrcRplLen;
po = po + nLen + nDstRplLen;

} while (p != NULL);
}
void contact(char str1[],char str2[])
{
 char *p1,*p2;
 int length1 = 0,length2 = 0;
 int i;
 p1 = str1;
 p2 = str2;
 while(*p1)
 {
  p1++;
  length1++;
 }
 while(*p2)
 {
  p2++;
  length2++;
 }
 for(i = 0;i < length1;i++)
  str2[length2+i] = str1[i];
 str2[length1+length2] = '\0';
}
int file_exists(char *filename)
{
    return (access(filename, 0) == 0);
}
int main()
{
    char c=GetSystemDisk();
    char order[255]="C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\regasm.exe /codebase /tlb";
    char path[255]="C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\regasm.exe";
    order[0]=c;
    int existFile=file_exists(path);
    char result[400];
    char szFull[400];
    GetModuleFileName(NULL,szFull,400);
    if(existFile!=1){
        printf("安装.NET运行时,请等待....\n");
        char result2[400];
        strrpl(result2,szFull,"patentstart.exe","2.0.exe");
        system(result2);
    }
    //启动路径


    strrpl(result,szFull,"patentstart.exe","PatentActiveX.dll");
    printf("%s\n",result);
    int resultLength=strlen(result);
    //
    char dllPath[500];
    dllPath[0]='"';
    int j=1;
    for(;j<=resultLength;j++){
        dllPath[j]=result[j-1];
    }
    dllPath[j]='"';
    dllPath[j+1]='\0';
    printf("%s\n",dllPath);
    //

    char fullOrder[900];
    int orderLength=strlen(order);
    int dllPathLength=strlen(dllPath);
    int i=0;
    for(;i<orderLength;i++){
        fullOrder[i]=order[i];
    }
    fullOrder[orderLength]=' ';
    for(i=orderLength+1;i<=orderLength+dllPathLength+1;i++){
        fullOrder[i]=dllPath[i-orderLength-1];
    }
    printf("%s\n",fullOrder);
    system(fullOrder);
    //system("cls");
    printf("注册成功,刷新IE页面有效\n");
    MessageBox(NULL,"注册成功,刷新IE页面有效","提示",MB_OK);
    return 0;
}
posted @ 2013-06-18 12:06  [秦时明月]  阅读(458)  评论(1编辑  收藏  举报