delphi调用windows下程序的问题!!急(20分)

  • 主题发起人 主题发起人 zl_cch
  • 开始时间 开始时间
Z

zl_cch

Unregistered / Unconfirmed
GUEST, unregistred user!
小弟只知道有个winexec(),但是只能打开exe文件,如何用delphi调用windows下的程序,比如打开某个txt文本或者word文档,不用什么复杂的方法就根据文件后缀名来判断用什么来打来就行,希望大家帮帮忙了!!
 
uses shellapi;<br>shellexecute(handle,nil,pchar(your file name),nil,nil,sw_show);
 
shellexcute 是个api函数你试试行不行
 
uses shellapi;<br>var<br>&nbsp;hDesktop: THandle;<br>begin<br>&nbsp;if stProgram[tmpint] = 'Dos' then<br>&nbsp; &nbsp;ShellExecute(0, 'open', 'cmd', nil, nil, SW_SHOWNORMAL);<br>&nbsp;if stProgram[tmpint] = '我的电脑' then<br>&nbsp; &nbsp;ShellExecute(0, 'open', 'explorer.exe', '::{20D04FE0-3AEA-1069-A2D8-08002B30309D}', nil, SW_NORMAL);<br>&nbsp;if stProgram[tmpint] = '资源管理器' then<br>&nbsp; &nbsp;ShellExecute(0, 'open', 'explorer.exe', nil, nil, sw_normal);<br>&nbsp;if stProgram[tmpint] = '记事本' then<br>&nbsp; &nbsp;ShellExecute(0, 'open', 'notepad', nil, nil, sw_normal);<br>&nbsp;if stProgram[tmpint] = '注册表' then<br>&nbsp; &nbsp;ShellExecute(0, 'open', 'regedit', nil, nil, sw_normal);<br>&nbsp;if stProgram[tmpint] = '计算器' then<br>&nbsp; &nbsp;ShellExecute(0, 'open', 'calc', nil, nil, sw_normal);<br>&nbsp;if stProgram[tmpint] = '画笔' then<br>&nbsp; &nbsp;ShellExecute(0, 'open', 'msPaint', nil, nil, sw_normal);<br>&nbsp;if stProgram[tmpint] = '重启' then ShutDown(4);<br>&nbsp;if stProgram[tmpint] = '关机' then ShutDown(5);<br>&nbsp;if stProgram[tmpint] = '注销' then ShutDown(2);<br>&nbsp;if stProgram[tmpint] = '控制面板' then<br>&nbsp; &nbsp;ShellExecute(0, 'open', 'rundll32.exe', 'shell32.dll,Control_RunDLL ', nil, sw_normal);<br>&nbsp;if stProgram[tmpint] = '辅助功能选项' then<br>&nbsp; &nbsp;ShellExecute(0, 'open', 'rundll32.exe', 'shell32.dll,Control_RunDLL access.cpl', nil, SW_SHOWNORMAL);<br>&nbsp;if stProgram[tmpint] = '添加和删除程序' then<br>&nbsp; &nbsp;ShellExecute(0, 'open', 'rundll32.exe', 'shell32.dll,Control_RunDLL appwiz.cpl', nil, SW_SHOWNORMAL);<br>&nbsp;if stProgram[tmpint] = '显示属性' then<br>&nbsp; &nbsp;ShellExecute(0, 'open', 'rundll32.exe', 'shell32.dll,Control_RunDLL desk.cpl', nil, SW_SHOWNORMAL);<br>&nbsp;if stProgram[tmpint] = '区域选项' then<br>&nbsp; &nbsp;ShellExecute(0, 'open', 'rundll32.exe', 'shell32.dll,Control_RunDLL intl.cpl', nil, SW_SHOWNORMAL);<br>&nbsp;if stProgram[tmpint] = '游戏控制器' then<br>&nbsp; &nbsp;ShellExecute(0, 'open', 'rundll32.exe', 'shell32.dll,Control_RunDLL joy.cpl', nil, SW_SHOWNORMAL);<br>&nbsp;if stProgram[tmpint] = '鼠标属性' then<br>&nbsp; &nbsp;ShellExecute(0, 'open', 'rundll32.exe', 'shell32.dll,Control_RunDLL main.cpl', nil, SW_SHOWNORMAL);<br>&nbsp;if stProgram[tmpint] = '声音和多媒体属性' then<br>&nbsp; &nbsp;ShellExecute(0, 'open', 'rundll32.exe', 'shell32.dll,Control_RunDLL mmsys.cpl', nil, SW_SHOWNORMAL);<br>&nbsp;if stProgram[tmpint] = '调制解调器' then<br>&nbsp; &nbsp;ShellExecute(0, 'open', 'rundll32.exe', 'shell32.dll,Control_RunDLL modem.cpl', nil, SW_SHOWNORMAL);<br>&nbsp;if stProgram[tmpint] = '系统特性' then<br>&nbsp; &nbsp;ShellExecute(0, 'open', 'rundll32.exe', 'shell32.dll,Control_RunDLL sysdm.cpl', nil, SW_SHOWNORMAL);<br>&nbsp;if stProgram[tmpint] = '时间日期属性' then<br>&nbsp; &nbsp;ShellExecute(0, 'open', 'rundll32.exe', 'shell32.dll,Control_RunDLL timedate.cpl', nil, SW_SHOWNORMAL);<br>&nbsp;if stProgram[tmpint] = '屏幕保护' then<br>&nbsp; &nbsp;SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_SCREENSAVE, 0);<br>&nbsp;if stProgram[tmpint] = '隐藏桌面' &nbsp;then<br>&nbsp;begin<br>&nbsp; &nbsp;hDesktop := FindWindow('Progman', nil);<br>&nbsp; &nbsp;ShowWindow(hDesktop, SW_HIDE);<br>&nbsp;end;<br>&nbsp;if stProgram[tmpint] = '显示桌面' then<br>&nbsp;begin<br>&nbsp; &nbsp;hDesktop := FindWindow('Progman', nil);<br>&nbsp; &nbsp;ShowWindow(hDesktop, SW_SHOW);<br>&nbsp;end<br>&nbsp;else<br>&nbsp; &nbsp;ShellExecute(0, 'open', pchar(stProgram[tmpint]), nil, nil, sw_normal); &nbsp;<br>
 
就当我路过!
 
app2001回的好啊
 
我见过了,还老样了。
 
后退
顶部