[vc++]写入证书

来源:互联网 发布:古风额饰淘宝 编辑:程序博客网 时间:2024/05/17 01:40
DWORD num=0;if(mApplet.getUSBKeyLists(mOut,num)!=0){MessageBox(_T("获取设备失败"),_T("提示"),MB_OK|MB_ICONERROR);}if(mApplet.openDevice(mOut[0]) == false){MessageBox(_T("请插入USBKey"),_T("提示"),MB_OK|MB_ICONERROR);}FILE* file;file=fopen("test.cer","rb");// localfile文件名fseek(file,0,SEEK_SET);fseek(file,0,SEEK_END);unsigned int fileLength=ftell(file);// longBytes就是文件的长度fseek(file,0,SEEK_SET);BYTE filetemp[1024],filebuf[1024];fread(filetemp,1,fileLength,file);filebuf[0] = (fileLength>>8)&0xFF;filebuf[1] = fileLength&0xFF;for(int i=0;i<fileLength;i++){filebuf[i+2]=filetemp[i];}AllocConsole();                     // 打开控制台资源freopen( "CONOUT$", "w+t", stdout );// 申请写freopen( "CONIN$", "r+t", stdin );  // 申请读for(int i=0;i<fileLength;i++){printf("%02X ",filebuf[i]);}char ch = getchar();                // 读数据FreeConsole();                      // 释放控制台资源if(mApplet.writeCertInfo(&mOut[0],filebuf,&fileLength)==false){MessageBox(_T("ERROR"),_T("提示"),MB_OK|MB_ICONERROR);}

原创粉丝点击