home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form dllparam
- Caption = "DLL parameter tester"
- ClientHeight = 4725
- ClientLeft = 1080
- ClientTop = 1515
- ClientWidth = 7365
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- LinkMode = 1 'Source
- LinkTopic = "Form1"
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 4725
- ScaleWidth = 7365
- Begin VB.CommandButton cmdObj3
- Caption = "Changes Obj"
- Height = 375
- Left = 3720
- TabIndex = 25
- Top = 4140
- Width = 1695
- End
- Begin VB.CommandButton cmdObj2
- Caption = "Object2"
- Height = 375
- Left = 5520
- TabIndex = 24
- Top = 3720
- Width = 855
- End
- Begin VB.CommandButton cmdBytes
- Caption = "Bytes"
- Height = 375
- Left = 4440
- TabIndex = 23
- Top = 2160
- Width = 855
- End
- Begin VB.CommandButton cmdRecObj
- Caption = "Receives Object"
- Height = 375
- Left = 3720
- TabIndex = 22
- Top = 3720
- Width = 1695
- End
- Begin VB.CommandButton cmdDate
- Caption = "Date"
- Height = 375
- Left = 6480
- TabIndex = 21
- Top = 2160
- Width = 735
- End
- Begin VB.CommandButton Command3
- Caption = "Variant ByRef"
- Height = 375
- Left = 5520
- TabIndex = 20
- Top = 3240
- Width = 1695
- End
- Begin VB.CommandButton Command2
- Caption = "VariantByVal"
- Height = 375
- Left = 3720
- TabIndex = 19
- Top = 3240
- Width = 1695
- End
- Begin VB.CommandButton Command1
- Caption = "VBArray"
- Height = 375
- Left = 5400
- TabIndex = 18
- Top = 2160
- Width = 975
- End
- Begin VB.CommandButton TestIntByval
- Caption = "ReceivesInteger(5)"
- Height = 375
- Left = 240
- TabIndex = 0
- Top = 240
- Width = 2175
- End
- Begin VB.CommandButton TestIntByref
- Caption = "Add5To5"
- Height = 375
- Left = 2640
- TabIndex = 4
- Top = 240
- Width = 1575
- End
- Begin VB.CommandButton TestLongByval
- Caption = "ReceivesLong(6)"
- Height = 375
- Left = 240
- TabIndex = 1
- Top = 720
- Width = 2175
- End
- Begin VB.CommandButton TestLongByref
- Caption = "Add5To6"
- Height = 375
- Left = 2640
- TabIndex = 5
- Top = 720
- Width = 1575
- End
- Begin VB.CommandButton TestSingleByval
- Caption = "ReceivesSingle(1.59)"
- Height = 375
- Left = 240
- TabIndex = 2
- Top = 1200
- Width = 2175
- End
- Begin VB.CommandButton TestSingleByref
- Caption = "Add5To1.59"
- Height = 375
- Left = 2640
- TabIndex = 6
- Top = 1200
- Width = 1575
- End
- Begin VB.CommandButton TestCurrencyByval
- Caption = "ReceivesCurrency(1.2345)"
- Height = 375
- Left = 4440
- TabIndex = 14
- Top = 240
- Width = 2775
- End
- Begin VB.CommandButton TestDoubleByval
- Caption = "ReceivesDouble(3.145)"
- Height = 375
- Left = 240
- TabIndex = 3
- Top = 1680
- Width = 2175
- End
- Begin VB.CommandButton TestDoubleByref
- Caption = "Add5To3.145"
- Height = 375
- Left = 2640
- TabIndex = 7
- Top = 1680
- Width = 1575
- End
- Begin VB.CommandButton TestCurrencyByref
- Caption = "AddPennyToCurrency(1.23)"
- Height = 375
- Left = 4440
- TabIndex = 15
- Top = 720
- Width = 2775
- End
- Begin VB.CommandButton TestString
- Caption = "ReceivesString ""Hello"""
- Height = 375
- Left = 240
- TabIndex = 8
- Top = 2160
- Width = 2175
- End
- Begin VB.CommandButton TestStringChange
- Caption = "Adds'!'to""Hello"""
- Height = 375
- Left = 2640
- TabIndex = 9
- Top = 2160
- Width = 1575
- End
- Begin VB.CommandButton TestVBString
- Caption = "ReceivesVBString(""String to DLL"")"
- Height = 375
- Left = 240
- TabIndex = 10
- Top = 2760
- Width = 3375
- End
- Begin VB.CommandButton TestUserType
- Caption = "ReceivesUserType(1,2,3,4)"
- Height = 375
- Left = 4440
- TabIndex = 13
- Top = 1200
- Width = 2775
- End
- Begin VB.CommandButton TestVBStringChange
- Caption = "ChangesVBString(""Short"")"
- Height = 375
- Left = 240
- TabIndex = 11
- Top = 3240
- Width = 3375
- End
- Begin VB.CommandButton TestAddUserString
- Caption = "AddUserString"
- Height = 375
- Left = 4440
- TabIndex = 17
- Top = 1680
- Width = 1455
- End
- Begin VB.CommandButton ReceivesIArray
- Caption = "Int Array"
- Height = 375
- Left = 6000
- TabIndex = 16
- Top = 1680
- Width = 1215
- End
- Begin VB.CommandButton ReturnVBString
- Caption = "ReturnsVBString()"
- Height = 375
- Left = 240
- TabIndex = 12
- Top = 3720
- Width = 3375
- End
- Attribute VB_Name = "dllparam"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- ' DLL parameter test program
- ' Copyright (c) 1995-1997, by Desaware
- ' All rights reserved
- ' This program is used to test the VB/DLL interface
- ' functions defined in APIGid32.dll
- Private Sub cmdBytes_Click()
- Dim b As Byte
- b = ReceivesBytes(65, 66)
- MsgBox "Received Byte " & Chr$(b)
- End Sub
- Private Sub cmdDate_Click()
- Dim d, t As Date
- d = Now()
- t = UsesDate(d)
- MsgBox "Tommorow is " & t
- End Sub
- Private Sub cmdObj2_Click()
- Dim o As Object
- Set o = ReceivesObject2(cmdObj2)
- MsgBox "Object caption is " & o.Caption
- End Sub
- Private Sub cmdObj3_Click()
- Dim orig$, final$
- Dim o As Object
- Set o = cmdObj3
- orig$ = o.Caption
- ChangesObject cmdObj2, o
- final$ = o.Caption
- MsgBox "Orig: " & orig$ & " Now: " & final$
- End Sub
- Private Sub cmdRecObj_Click()
- ReceivesObject cmdRecObj
- End Sub
- Private Sub Command1_Click()
- ReDim x(5) As Integer
- Dim y%
- x(0) = 5
- x(1) = 6
- x(2) = 7
- x(3) = 8
- x(4) = 9
- y% = ReceivesVBArray(x())
- MsgBox "New result of x(0) (was 5) is " & x(0)
- End Sub
- Private Sub Command2_Click()
- Dim v As Variant
- Dim res%
- v = "hello"
- res% = ReceivesVariantByVal(v)
- End Sub
- Private Sub Command3_Click()
- Dim v As Variant, rs As Variant
- Dim res%
- v = "hello"
- rs = ReceivesVariant(v)
- MsgBox "V is " & v
- MsgBox "rs is " & rs
- End Sub
- Private Sub Command4_Click()
- End Sub
- ' This is a test of passing a pointer to a numeric array
- ' Note the unique DLL call
- Private Sub ReceivesIArray_Click()
- ReDim x(4) As Integer
- Dim u As UserType
- Dim i As Integer
- x(0) = 1
- x(1) = 3
- x(2) = 9
- x(3) = 81
- ' Pass a pointer to the first element of the array.
- ' The DLL has no way of knowing how long the array is
- ' unless you define a length parameter for the function.
- ReceivesIntArray x(0)
- MsgBox "First entry is now " & x(0)
- ' Note that only the first value is correct, and
- ' that the change does not take effect
- u.e(0) = 88
- u.e(1) = 89
- u.e(2) = 90
- u.e(3) = 91
- ReceivesIntArray u.e(0)
- MsgBox "First entry is now " & u.e(0)
- u.a = 60
- u.b = 61
- u.c = 62
- u.d = 63
- ReceivesIntArray u.a
- MsgBox "First entry is now " & u.a
- End Sub
- ' A DLL function returning a Visual Basic String
- Private Sub ReturnVBString_Click()
- a$ = ReturnsVBString()
- MsgBox a$, 0, "ReturnsVBString"
- End Sub
- ' Show how to access strings inside user defined types
- Private Sub TestAddUserString_Click()
- Dim u As UserType
- ' Note - this is call by reference, the DLL can change
- ' the value of u
- u.s = "orignal string"
- AddUserString u
- MsgBox u.s, 0, "String in usertype changed"
- End Sub
- ' Passing currency by reference
- Private Sub TestCurrencyByref_Click()
- Dim c@
- c@ = 1.23
- AddPennyToCurrency c@
- MsgBox Str$(c@), 0, "AddPennyToCurrency"
- End Sub
- ' Passing currency by value and returning currency
- Private Sub TestCurrencyByval_Click()
- Dim c@
- c = 1.2345
- c = ReceivesCurrency(c)
- End Sub
- ' Passing doubles by reference
- Private Sub TestDoubleByref_Click()
- d# = 3.145
- Add5ToDouble d#
- MsgBox Str$(d#), 0, "Add5ToDouble"
- End Sub
- ' Passing doubles by value and returning doubles
- Private Sub TestDoubleByval_Click()
- d# = ReceivesDouble(3.145)
- End Sub
- ' Passing integers by reference
- Private Sub TestIntByref_Click()
- x% = 5
- Add5ToInteger x%
- MsgBox Str$(x%), 0, "Add5ToInteger"
- End Sub
- ' Passing integers by value and returning integers
- Private Sub TestIntByval_Click()
- x% = ReceivesInteger(5)
- End Sub
- ' Passing longs by reference
- Private Sub TestLongByref_Click()
- y& = 6
- Add5ToLong y&
- MsgBox Str$(y&), 0, "Add5ToLong"
- End Sub
- ' Passing longs by value and returning longs
- Private Sub TestLongByval_Click()
- y& = ReceivesLong(6)
- End Sub
- ' Passing singles by reference
- Private Sub TestSingleByref_Click()
- f! = 1.59
- Add5ToSingle f!
- MsgBox Str$(f!), 0, "Add5ToSingle"
- End Sub
- ' Passing singles by value and returning singles
- Private Sub TestSingleByval_Click()
- f! = ReceivesSingle(1.59)
- End Sub
- ' Passing strings (null terminated)
- ' Always by reference
- Private Sub TestString_Click()
- ReceivesString "Hello"
- End Sub
- ' Passing and modifying strings (null terminated)
- ' Always by reference
- Private Sub TestStringChange_Click()
- ' Null terminated string is passed to the routine
- ' x$ must be preinitialized to the maximum length.
- ' The DLL may change the contents of the string, but
- ' must never go past the null terminator
- x$ = "Hello"
- ChangesString x$
- MsgBox x$, 0, "ChangesString"
- End Sub
- ' Passing user defined types
- ' Always by reference
- Private Sub TestUserType_Click()
- Dim u As UserType
- u.a = 1
- u.b = 2
- u.c = 3
- u.d = 4
- u.e(0) = 5
- u.e(1) = 6
- u.e(2) = 7
- u.e(3) = 8
- u.s2 = "ABCD"
- u.st = 99
- ' Note - this is call by reference, the DLL can change
- ' the value of u
- ReceivesUserType u
- u = ReturnUserType()
- MsgBox "New user type received: " & u.a & u.b & u.c & u.d
- End Sub
- ' Passing Visual Basic strings
- Private Sub TestVBString_Click()
- ReceivesVBString "String to DLL"
- End Sub
- ' Passing and modifying Visual Basic strings
- ' Note - no length restrictions apply
- Private Sub TestVBStringChange_Click()
- a$ = "Short"
- ChangesVBString a$
- MsgBox a$, 0, "ChangesVBString"
- End Sub
-