1、怎样在一程序运行时打开另一外部程序,程序关闭时也关闭另一外部程序?2、怎样将一个字符串{包括中英文}中的中文字符串用中文拼音的第一个字母表示,而英文字符则不变地显示出来?
解决方案 »
- 有没有用DELPHI做过短信发送系统呢?给点代码参考一下 谢谢
- DELPHI/JAVA五年经验程序员求职,请各位兄弟多支持。谢谢。
- ■■【高分请教】回答立刻给分:请问如何截屏得到256色的图?
- 文件读写要命,真急呀
- dbgrid的问题:在线
- 接收邮件的问题,谢谢帮忙!!!
- 自爆虚拟摄像头效果软件,转让
- 关于线程传送消息主程序怎样接收的问题
- 请问用BCB如何实现DELPHI的查询功能,如DELPHI : table1.findkey([edit1.text,exit2.text]). 谢谢!
- FastMM使用请教
- 高水准报表--三层结构中打印技术取得新进展
- 使用corba开发多层应用,各层需要什么支持?
ShellExecute(handle, 'close', 'Your.exe', nil, nil, SW_SHOWNORMAL);
public
ProcessInfo: TProcessInformation;
{ Public declarations }
end;procedure TForm1.Button1Click(Sender: TObject);
var
filename:string;
StartupInfo: TStartupInfo;begin
FillChar(StartupInfo, SizeOf(TStartupInfo), 0);
with StartupInfo do
begin
cb := SizeOf(TStartupInfo);
dwFlags := STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK;
wShowWindow := SW_SHOW;
end;
filename:='g:\project1.exe';
createprocess(pchar(filename),nil,nil,nil,false,NORMAL_PRIORITY_CLASS,nil,nil,StartupInfo,ProcessInfo);end;procedure TForm1.Button2Click(Sender: TObject);
var
ec:cardinal;
begin
getexitcodeprocess(ProcessInfo.hProcess,ec);
TerminateProcess(ProcessInfo.hProcess,ec);
end;
var
PStartupInfo: TStartupInfo;
aProcessInfo: TProcessInformation;
begin
FillChar(PStartupInfo, SizeOf(PStartupInfo), 0);
PStartupInfo.cb:=SizeOf(PStartupInfo);
CreateProcess(nil,
PChar(ServerPath+'SmartUpg.exe Y '+ Trim(UserRecord.UserID)+' '+tbUser.FieldByName('PASSWD').AsString),
nil, nil, False, DETACHED_PROCESS, nil, nil, PStartupInfo, aProcessInfo);
CloseHandle(aProcessInfo.hThread);
CloseHandle(aProcessInfo.hProcess);
end;当主程序关闭,线程打开的程序也同时关闭
procedure TForm1.FormCreate(Sender: TObject);
begin
WinExec('notepad.exe',SW_SHOWMAXIMIZED);
end;//程序关闭时也关闭另一外部程序
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
h:THandle;
begin
h:=findwindow(nil,'无标题 - 记事本'); //注意修改为自己的窗口标题
if h <> 0 then sendmessage(h,WM_CLOSE,0,0);
end;//2、怎样将一个字符串{包括中英文}中的中文字符串用中文拼音的第一个字母表示,而英文字符则不变地显示出来?
function GetHzPy(const AHzStr: string): string;
const
ChinaCode: array[0..25, 0..1] of Integer = ((1601, 1636), (1637, 1832), (1833, 2077),
(2078, 2273), (2274, 2301), (2302, 2432), (2433, 2593), (2594, 2786), (9999, 0000),
(2787, 3105), (3106, 3211), (3212, 3471), (3472, 3634), (3635, 3722), (3723, 3729),
(3730, 3857), (3858, 4026), (4027, 4085), (4086, 4389), (4390, 4557), (9999, 0000),
(9999, 0000), (4558, 4683), (4684, 4924), (4925, 5248), (5249, 5589));
var
i, j, HzOrd: integer;
begin
i := 1;
while i <= Length(AHzStr) do
begin
if (AHzStr[i] >= #160) and (AHzStr[i + 1] >= #160) then
begin
HzOrd := (Ord(AHzStr[i]) - 160) * 100 + Ord(AHzStr[i + 1]) - 160;
for j := 0 to 25 do
begin
if (HzOrd >= ChinaCode[j][0]) and (HzOrd <= ChinaCode[j][1]) then
begin
Result := Result + char(byte('A') + j);
break;
end;
end;
Inc(i);
end else Result := Result + AHzStr[i];
Inc(i);
end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(gethzpy('你好hello')); //结果为NHhello
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
setwindowlong(application.handle,gwl_exstyle,ws_ex_toolwindow);
end;