Danmark vil mindske afhængigheden af globale techgiganter, men det kræver mere end politiske formuleringer og strategier, understreger PROSA’s formand Niels Bertelsen.
Private Declare Function CreatePipe Lib "kernel32" (phReadPipe As Long, phWritePipe As Long, lpPipeAttributes As Any, ByVal nSize As Long) As Long Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, ByVal lpBuffer As String, ByVal nNumberOfBytesToRead As Long, lpNumberOfBytesRead As Long, ByVal lpOverlapped As Any) As Long Private Declare Function CreateProcessA Lib "kernel32" (ByVal lpApplicationName As Long, ByVal lpCommandLine As String, lpProcessAttributes As Any, lpThreadAttributes As Any, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, lpStartupInfo As Any, lpProcessInformation As Any) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Private Declare Function PeekNamedPipe Lib "kernel32" (ByVal hNamedPipe As Long, lpBuffer As Any, ByVal nBufferSize As Long, lpBytesRead As Long, lpTotalBytesAvail As Long, lpBytesLeftThisMessage As Long) As Long Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Type SECURITY_ATTRIBUTES nLength As Long lpSecurityDescriptor As Long bInheritHandle As Long End Type
Private Type STARTUPINFO cb As Long lpReserved As Long lpDesktop As Long lpTitle As Long 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 Const SW_HIDE As Long = 0 Private Const NORMAL_PRIORITY_CLASS As Long = &H20& Private Const STARTF_USESTDHANDLES As Long = &H100& Private Const STARTF_USESHOWWINDOW As Long = &H1
Public Function ExecuteCmd(ByVal strCommandline As String, Optional ByVal TimeOut As Long = 2000) As String Dim SI As STARTUPINFO Dim SA As SECURITY_ATTRIBUTES Dim PI As PROCESS_INFORMATION
Dim Result As Long Dim Success As Long
Dim hReadPipe As Long Dim hWritePipe As Long Dim lPeekData As Long Dim lngTimeOut As Long
Dim Length As Long Dim Buffer As String Dim strOut As String
With SA .nLength = Len(SA) .bInheritHandle = 1& .lpSecurityDescriptor = 0& End With
Result = CreatePipe(hReadPipe, hWritePipe, SA, 0)
If Result = 0 Then ExecuteCmd = "" 'CreatePipe failed Error! Exit Function End If
With SI .cb = Len(SI) .dwFlags = STARTF_USESTDHANDLES Or STARTF_USESHOWWINDOW .wShowWindow = SW_HIDE .hStdOutput = hWritePipe End With
Result = CreateProcessA(0&, strCommandline, SA, SA, 1&, _ NORMAL_PRIORITY_CLASS, 0&, _ 0&, SI, PI)
lngTimeOut = (GetTickCount + TimeOut)
Do Call PeekNamedPipe(hReadPipe, ByVal 0&, 0&, ByVal 0&, lPeekData, ByVal 0&) If lPeekData > 0 Then Buffer = Space$(lPeekData) Success = ReadFile(hReadPipe, Buffer, Len(Buffer), Length, 0&) If Success = 1 Then strOut = (strOut & Left(Buffer, Length)) Else strOut = "" 'ReadFile failed! End If Else Success = WaitForSingleObject(PI.hProcess, 0&) If Success = 0 Or GetTickCount >= lngTimeOut Then Exit Do End If End If Loop
Hej sjh Hvilken version er det skrevet til ? jeg bruger Microsoft Visual Basic 2005 Express Edition men kan ikke rigtig få det til at virke. Når jeg laver et modul og sætter din kode ind giver den en del fejl som jeg ikke lige kan forstå
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.