I'm converting some code from VB6 to .NET (2005) but it didn't manage to handle everything in the autoconvert. Now I have a few errors left in this code:
The stuff in magenta is giving errors. I am not sure what to do about the ByVal 0& stuff.Code:Private Declare Function ReadFile _ Lib "kernel32" ( _ ByVal hFile As Long, _ ByVal lpBuffer As Object, _ ByVal nNumberOfBytesToRead As Long, _ ByVal lpNumberOfBytesRead As Long, _ ByVal lpOverlapped As Object) As Long Do ' Add a DoEvents to allow more data to be written to the buffer for each call. ' This results in fewer, larger chunks to be read. 'DoEvents If ReadFile(hPipeRead, baOutput(0), BUFSIZE, lBytesRead, ByVal 0&) = 0 Then Exit Do End If If blnOEMConvert Then ' convert from "DOS" to "Windows" characters sNewOutput = CChar(CChar(CStr(lBytesRead))) Call OemToCharBuff(baOutput(0), sNewOutput, lBytesRead) Else ' perform no conversion (except to Unicode) sNewOutput = Left$(StrConv(baOutput(0), 64), lBytesRead) End If GetCommandOutput = GetCommandOutput & sNewOutput ' If you are executing an application that outputs data during a long time, ' and don't want to lock up your application, it might be a better idea to ' wrap this code in a class module in an ActiveX EXE and execute it asynchronously. ' Then you can raise an event here each time more data is available. 'RaiseEvent OutputAvailabele(sNewOutput) Loop




Reply With Quote