I have never written a Win32 application before but I recently purchased PBWin90 with the intention of learning and developing something useful. So, I have been struggling with COM syntax and being able to access the routines in a specific DLL.
Here is what does work in VB 2005 Express:
Question
I feel like I have looked through all the DOC's and samples and have hit a wall. So, any chance someone here on the board could duplicate the above VB in PB? It would be greatly appreciated.
Here is the include output from the PowerBasic COM Browser
Here is the DLL file: uniobjects.dll
Here is the TLB file: uniobjects.tlb
Here is the VB include file I converted to PB.
Thanks in advance.
Here is what does work in VB 2005 Express:
Code:
[URL="http://cdm-web.com/files/vb_unioaif.inc"]#INCLUDE "vb_unioaif.inc"[/URL] [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Form1_Load([/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]MyBase[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].Load[/SIZE] [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] objSession [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE] [/COLOR][/SIZE][SIZE=2]objSession = CreateObject(UV_SESSION_OBJECT)[/SIZE] [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] objSession [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Is[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE] [/COLOR][/SIZE][SIZE=2]MsgBox([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Error creating object"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], MsgBoxStyle.Critical)[/SIZE] [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Exit[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]' End the program[/COLOR][/SIZE] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE] [/COLOR][/SIZE][SIZE=2]objSession.UserName = [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"fredsmith"[/COLOR][/SIZE] [/COLOR][/SIZE][SIZE=2]objSession.Password = [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"password"[/COLOR][/SIZE] [/COLOR][/SIZE][SIZE=2]objSession.HostName = [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"host.example.com"[/COLOR][/SIZE] [/COLOR][/SIZE][SIZE=2]objSession.AccountPath = [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"/home/FREDSMITH"[/COLOR][/SIZE] [/COLOR][/SIZE][SIZE=2]objSession.Transport = 1[/SIZE] [SIZE=2]objSession.Connect()[/SIZE] [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] objSession.IsActive [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] objSession.HostType = UVT_UNIX [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE] [/COLOR][/SIZE][SIZE=2]MsgBox([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"You are connected to a UNIX server"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE] [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE] [/COLOR][/SIZE][SIZE=2]MsgBox([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"You are connected to a Windows NT system"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2])[/SIZE] [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE] [/COLOR][/SIZE][SIZE=2]objSession.Disconnect()[/SIZE] [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Else[/COLOR][/SIZE] [/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]'[/COLOR][/SIZE] [/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]' Check for Session errors - display message box with error code[/COLOR][/SIZE] [/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]' No error means the user cancelled the connection dialog box[/COLOR][/SIZE] [/COLOR][/SIZE][SIZE=2][COLOR=#008000][SIZE=2][COLOR=#008000]'[/COLOR][/SIZE] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] objSession.Error <> UVE_NOERROR [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE] [/COLOR][/SIZE][SIZE=2]MsgBox([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Unable to open connection :- "[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] & objSession.Error)[/SIZE] [SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE] [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][/COLOR][/SIZE]
I feel like I have looked through all the DOC's and samples and have hit a wall. So, any chance someone here on the board could duplicate the above VB in PB? It would be greatly appreciated.
Here is the include output from the PowerBasic COM Browser
Here is the DLL file: uniobjects.dll
Here is the TLB file: uniobjects.tlb
Here is the VB include file I converted to PB.
Thanks in advance.
Comment