I am trying to convert a VB Script program to VB.NET (2008 Express). The script uses Automation COM to access HLLAPI under the covers, Jolly Giant QWS3270). I am currently just trying to get knowledgeable with VB.NET, for a simple console application, calling WinHLLAPI DLL (Jolly Giant's QWS3270). I have many of the WinHLLAPI functions working just fine. The problem calls are those which require a string buffer to be passed in and that will be updated by the HLLAPI DLL. In each case, the string is not updated but the return code (in pos variable)
is 0 - so WinHLLAPI thinks it did something.
I have reduced my code to a small example below. This calls a HLLAPI function that does not require connecting to a session (just keeping things simple).
I have searched and searched the internet and EE. Most answers are from C++ perspective.
I am not writing C or C++, I am wrting VB.NET Express code, hopefully there is a VB.NET Express answer to this. There seem to be plenty of people using VB.NET to call a C/C++ DLL
and pass in a string using ByVal and get the string updated - but I do not seem to be able to.
Hopefully, someone in EE can help. Thank you
Option Explicit On
Imports System.Runtime.InteropServices
Module Module1
<DllImport("C:\Program Files\QWS3270 PLUS\whllapi.dll")> _
Sub WinHLLAPI(ByRef f As Long, ByVal s As String, ByRef l As Long, ByRef r As Long)
End Sub
Sub Main()
Call QuerySystem()
End
End Sub
Public Sub QuerySystem()
Dim str As String
Dim pos As Long
Dim length As Long
Dim number As Long
' HLLAPI function number 10: Query System
number = 20
' preallocated buffer area
str = Space(35)
' the length is not really needed, 35 is implied
length = Len(str)
' position is not needed here
pos = 0
' call hllapi function
WinHLLAPI(number, str, length, pos)
End Sub