| | | 小商品软件的加密方法 | | 2001-12-22·
·马杰勇··
| 上一页 1 2 ---- 这里关键的代码是启动一个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; |
---- 在FileName中给出DOS加密认证程序的名称(带绝对路径),在Visibility中给出是否需要DOS程序的窗口可见,一般设为不可见。这种方法在我们的多个小商品软件中使用,效果良好。
---- 需要注意的是这种加密方法在Windows NT中无法运行,因为NT不支持DOS程序直接访问硬件。考虑到操作系统最终会过渡到Windows NT,程序无法直接访问硬件,如何低成本地实现小商品的加密就是一个让人关心的问题。这方面我们还在探索,欢迎有经验的朋友介绍一下。
上一页 1 2 | | | 感谢
访问天极网,如果您觉得该文章涉及版权问题,请看这里!
|
|