---- 具体的实现方式是由应用程序调用Windows API启动DOS加密认证程序,并等待该程序结束,判定其返回码,以确定是否有钥匙盘。为此,需要对原来的DOS程序略加改动,将判定结果以返回码的形式输出,例如在Turbo C++ 3.0中使用exit(0)返回0,使用exit(1)返回1(至于DOS实现磁盘加密的方法由于资料很多,这里不作具体介绍)。而Windows应用程序读取到返回码以后,就可以确定下一步的动作。 更多内容请看常用软件加密宝典 加密与解密技术 软件插件专题,或 ---- 这里要害的代码是启动一个DOS程序,等待它结束,并得到返回码。请参看下面的Delphi函数WinExecAndWait32: Function WinExecAndWait32(FileName : String; Visibility : integer):dWord; var zAppName:array[0..512] of char; zCurDir:array[0..255] of char; WorkDir:String; StartupInfo:TStartupInfo; PRocessInfo:TProcessInformation; begin StrPCopy(zAppName,FileName); GetDir(0,WorkDir); StrPCopy(zCurDir,WorkDir); FillChar(StartupInfo,Sizeof(StartupInfo),#0); StartupInfo.cb := Sizeof(StartupInfo);
StartupInfo.dwFlags := STARTF_USESHOWWINDOW; StartupInfo.wShowWindow := Visibility; if not CreateProcess(nil, zAppName, { pointer to command line string } nil, { pointer to process security attributes } nil, { pointer to thread security attributes } false, { handle inheritance flag } CREATE_NEW_CONSOLE or { creation flags } NORMAL_PRIORITY_CLASS, nil, { pointer to new environment block } nil, { pointer to current Directory name } StartupInfo, { pointer to STARTUPINFO } ProcessInfo) then Result := 0 { pointer to PROCESS_INF } else begin WaitforSingleObject(ProcessInfo.hProcess,INFINITE); GetExitCodeProcess(ProcessInfo.hProcess,Result); end; end;