当前位置:主页>仓库管理软件> 列表

OCX可以调用外部执行程序吗?

销售管理软件版1楼: 我需要在网页上调用客户本机的可执行程序,不知是否可以用activeX的ocx实现?
例如: html --> ocx --> 打开exe
如果可以,如何调用exe?
(我试过在ocx里用shellexecute和winexec都无反应)

2楼: 可以啊,我在VB中是这样做的:
Public Sub Run(StrExePath As String) ''调用一个EXE文件,如果该文件已经存在,则激活它
Dim Res As Integer
Dim FileName As String
Dim StrCurrentDir As String
Dim IntPathLng As Integer

On Error GoTo Err_Handler
FileName = Dir(StrExePath)
IntPathLng = Len(StrExePath) - Len(FileName) - 1
StrCurrentDir = Left(StrExePath, IntPathLng)

''Res = Shell(StrExePath, vbNormalFocus) Shell函数无法设定EXE文件的运行起始路径,因此改用API函数ShellExecute
Res = ShellExecute(UserControl.hwnd, "open", StrExePath, (GcCode & " " & DocType & " 83"), StrCurrentDir, SW_SHOW + SW_RESTORE)
If Res < 32 Then Err.Raise 12345 + vbObjectError, App.EXEName, "调用可执行文件错误"
Exit Sub

Err_Handler:
Dim StrPrompt As String
StrPrompt = "系统调用失败(没有找到可执行文件)。" & vbCrLf
MsgBox StrPrompt
End Sub

Private Sub UserControl_Initialize()
NoError = True
GcCode = ""
DocType = ""
End Sub 如大管家财务软件

3楼: 用ShellExecute,我估计是你的程序执行路径没指定。

4楼: function run(str){
CallExe.DocType="1";
CallExe.GcCode=str;
CallExe.StrExePath="C:\GIS\CompleteDocNew.exe";
CallExe.Run();
}
/form>





5楼: 可了以,谢谢。是字串处理的错误。
winexec(pchar(''dxxxxxxxx.exe -ss''), sw_show); ----这样错误,没反应

改成这样就通过了:
var s: string;
s := ''dxxxxxxxx.exe -ss'';
winexec(pchar(s),sw_show);

6楼: 接受答案了.