Rouven: Kann ich Perl aus Access heraus starten?

Beitrag lesen

Hello,

für einen synchronen Start einer Shell-Anwendung kannst du dich der Windows-API bedienen. Nachfolgende Teile musst du in einem VBA-Modul unterbringen:
'------------------------------------------------------
Private Declare Function CloseHandle Lib "kernel32" ( _
    ByVal hObject As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" ( _
    ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" ( _
    ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
    ByVal dwProcessId As Long) As Long

' ShellX stellt eine Erweiterung der Shell-Funktion von VBA dar, die es erlaubt,
' das Ende des ausgeführten Prozesses abzuwarten
Public Function ShellX( _
    ByVal PathName As String, _
    Optional ByVal WindowStyle As VbAppWinStyle = vbMinimizedFocus, _
    Optional ByVal Events As Boolean = True _
  ) As Long

'Deklarationen:
  Const STILL_ACTIVE = &H103&
  Const PROCESS_QUERY_INFORMATION = &H400&
  Dim ProcId As Long
  Dim ProcHnd As Long

'Prozess-Handle holen:
  ProcId = Shell(PathName, WindowStyle)
  ProcHnd = OpenProcess(PROCESS_QUERY_INFORMATION, True, ProcId)

'Auf Prozess-Ende warten:
  Do
    If Events Then DoEvents
    GetExitCodeProcess ProcHnd, ShellX
  Loop While ShellX = STILL_ACTIVE

'Aufräumen:
  CloseHandle ProcHnd

End Function
'------------------------------------------------------

Anschließend verwendest du die ShellX-Funktion als wäre es die normale Shell-Funktion.

MfG
Rouven

--
-------------------
sh:| fo:} ch:? rl:( br:& n4:{ ie:| mo:} va:) js:| de:] zu:| fl:( ss:) ls:& (SelfCode)
Computer programming is tremendous fun. Like music, it is a skill that derives from an unknown blend of innate talent and constant practice. Like drawing, it can be shaped to a variety of ends: commercial, artistic, and pure entertainment. Programmers have a well-deserved reputation for working long hours but are rarely credited with being driven by creative fevers. Programmers talk about software development on weekends, vacations, and over meals not because they lack imagination, but because their imagination reveals worlds that others cannot see. -- Larry OBrien and Bruce Eckel in Thinking in C#