Hallo Thomas,
Post by Thomas GahlerIch möchte wirklich nur die .dll registrieren. Kannst du mir hier kurz
weiterhelfen (auch wenn wir in einer WordVBA-NG sind). Danke.
Dafür nehme ich in VB6 eine Process-Klasse (unbekannter Autor), der ich Pfad
und Name der RegSvr32 übergebe und als Parameter "/s Pfad\DLLName".
Die Klasse hat eine Function IsTerminated. Damit wartet der Aufrufer-Code
solange, bis die DLL-Registrierung abgeschlossen ist.
Hang loose, Hartwig
Option Explicit
'------------------------------------------------------------------------------
' KLASSE: clsProcess
' ------
'
' Ein Object der Klasse clsProcess wird verwendet, um eine Applikation zu
starten,
' und den Status derselbigen ermitteln zu können
' Die Benutzung der Klasse ist sowohl mit 16Bit als auch mit 32 Bit mit
identischer
' Syntax möglich.
'
'
' Interface
' ---------
'
' Property Programmname Name des zu startenden Programms
' Property Arguments Zusätzliche Argumente
' Method Exec Ausführen
' Property IsTerminated Ist der Process beendet.
'----------------------------------------------------------------
'Im aufrufenden Modul
' Dim Process As New clsProcess
' Process.ProgramName = "attrib"
' Process.Arguments = "-r " & "C:\Pfad\Unterpfad\*.* /s"
' Process.Exec
' Do While Not Process.IsTerminated
' DoEvents
' Loop
' DoEvents
'----- API Declarationen ---------------------------------------
#If Win32 Then
Private Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal _
hHandle As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CreateProcessA Lib "kernel32" (ByVal _
lpApplicationName As Long, ByVal lpCommandLine As String, ByVal _
lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, _
ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, _
ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, _
lpStartupInfo As STARTUPINFO, lpProcessInformation As _
PROCESS_INFORMATION) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal _
hObject As Long) As Long
Private Const NORMAL_PRIORITY_CLASS = &H20&
Private Const INFINITE = -1&
#Else
Private Declare Function GetModuleUsage Lib "Kernel" (ByVal hModule
As Integer) As Integer
#End If
'------------------------------------------------------------------------------------
'-------------------------------------------------------------------------------------
' Internal Member
'------------------------------------------------------------------------------------
'-------------------------------------------------------------------------------------
#If Win32 Then
Private m_ProcessInfo As PROCESS_INFORMATION
Private m_StartupInfo As STARTUPINFO
#Else
Private ApplicationHandle As Integer
#End If
Private m_ProgramName As String
Private m_Arguments As String
'------------------------------------------------------------------------------------
'-------------------------------------------------------------------------------------
' INTERFAC
'------------------------------------------------------------------------------------
'-------------------------------------------------------------------------------------
'-------------------------------------------------------------------------------------
' ProgramName
' -----------
'
' Name des zu startenden Programmes (ohne Argumente)
'
------------------------------------------------------------------------------------
Public Property Let ProgramName(szName As String)
m_ProgramName = szName
'MsgBox m_ProgramName
End Property
'
------------------------------------------------------------------------------------
' Argmuments
' ----------
'
' zusätzliche Argumente für das zu startende Programm
'
'
------------------------------------------------------------------------------------
Public Property Let Arguments(szArg As String)
m_Arguments = szArg
'MsgBox m_Arguments
End Property
'
------------------------------------------------------------------------------------
' Exec()
' ----
'
' Starten des Programmes und sichern der relevanten Informationen in den
internen
' Member-Variablen
'
Public Sub Exec()
#If Win32 Then
Dim ret As Long
' Initialisierung der STARTUPINFO Structure.
' (im ersten Element erwartet die API-Funktion die Grösse der
Struktur)
m_StartupInfo.cb = Len(m_StartupInfo)
' Start der Applikation über die API-Funktion CreateProcess anstelle
' der Verwendung der VB-internen Shell-Funktion
'
ret = CreateProcessA(0&, m_ProgramName & " " & m_Arguments, 0&, 0&,
1&, _
NORMAL_PRIORITY_CLASS, 0&, 0&, m_StartupInfo, m_ProcessInfo)
#Else
' In der 16-Bit Variante wird das Programm über die interne
Shell-Funktion
' gestartet
'
ApplicationHandle = Shell(m_ProgramName & " " & m_Arguments, 1)
#End If
End Sub
'
------------------------------------------------------------------------------------
' IsTerminated
' ------------
'
' Liefert zurück, ob die gestartete Applikation beendet wurde
'
'
------------------------------------------------------------------------------------
Public Property Get IsTerminated() As Boolean
#If Win32 Then
IsTerminated = (WaitForSingleObject(m_ProcessInfo.hProcess, 10) = 0)
#Else
IsTerminated = (GetModuleUsage(ApplicationHandle) = 0)
#End If
End Property