to 楼主:
如何jsp 如何调active 我就不说了!
active 如何调.exe 我就不说了!
下面这个MiniShell 你看看吧!
unit Miniddczp;
{$WARN SYMBOL_PLATFORM OFF}
interface
uses
SysUtils, shellapi, Registry, WINDOWS, ComObj, ActiveX, Project1_TLB, StdVcl;
const
C_MainKey = 'DDTECH';
C_DDCZP = 'DDCZP';
type
TMiniDDCZP = class(TAutoObject, IMiniDDCZP)
protected
procedure Set_LGUID(const Value: WideString);
safecall;
procedure Set_LUSER(const Value: WideString);
safecall;
{ Protected declarations }
public
FGUID: string;
FUSER: string;
end;
implementation
uses ComServ;
procedure DeleteKey(value: string);
var
Reg: TRegistry;
begin
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_LOCAL_MACHINE;
if Reg.OpenKey('/Software/Microsoft/Windows/CurrentVersion/' + C_MainKey, true) then
begin
reg.DeleteValue(value);
Reg.DeleteKey(value);
end;
finally
Reg.Free;
end;
end;
procedure SetKey(value: string);
var
Reg: TRegistry;
begin
Reg := TRegistry.Create;
try
//声明注册表主键
Reg.RootKey := HKEY_LOCAL_MACHINE;
//打开注册表路径。。。。。。。。
if Reg.OpenKey('/Software/Microsoft/Windows/CurrentVersion/' + C_MainKey, True) then
begin
/// 打开成功, 写入注册表。。。。
Reg.WriteString(value, ParamStr(0));
// MyApp 项名
// ParamStr(0) 当前的操作项
//关闭
Reg.CloseKey;
end;
finally
// 释放内存
Reg.Free;
end;
end;
function ReadKey(value: string): string;
var
Reg: TRegistry;
begin
result := '';
Reg := TRegistry.Create;
try
//声明注册表主键
Reg.RootKey := HKEY_LOCAL_MACHINE;
//打开注册表路径。。。。。。。。
if Reg.OpenKey('/Software/Microsoft/Windows/CurrentVersion/' + C_MainKey, True) then
begin
/// 打开成功, 写入注册表。。。。
result := Reg.ReadString(value);
// MyApp 项名
// ParamStr(0) 当前的操作项
//关闭
Reg.CloseKey;
end;
finally
// 释放内存
Reg.Free;
end;
end;
procedure TMiniDDCZP.Set_LGUID(const Value: WideString);
begin
FGUID := VALUE;
end;
procedure TMiniDDCZP.Set_LUSER(const Value: WideString);
var S: string;
begin
FUSER := VALUE;
s := ReadKey(c_ddczp);
if not fileexists(s) then
begin
MESSAGEBOX(0, '文件不存在...', '提示', mb_ok);
exit;
end;
ShellExecute(0, nil, PCHAR(S), PCHAR(FGUID + ' ' + FUSER), PCHAR(ExtractFilepath(S)), sw_ShowNormal);
end;
initialization
TAutoObjectFactory.Create(ComServer, TMiniDDCZP, Class_MiniDDCZP,
ciMultiInstance, tmApartment);
end.