Using PC*Miler Connect with Visual Basic
Contents
Using PC*Miler Connect from Visual Basic is very much like calling it from ‘C’: the declarations are different, but the calling sequences are the same. Please see the Visual Basic declaration file in your installation folder (usually C:\ALK Technologies\PCMILERXX\Connect
).
The sample project in this folder is not intended to be a complete application. Rather, it is a collection of illustrative examples of how to open an engine connection, create a trip, extract a report, look up city names, and create your own user interface on top of PC*Miler Connect.
NOTE: Also refer to pcmstrip.h and pcmsinit.h in
C:\ALK Technologies\PCMILERXX\Connect\C_CPP\StaticLink\pcmsrv32
.
Caveats for Visual Basic
Be sure to use the function prototypes in the Visual Basic declaration file to get the proper argument types.
- First, server IDs must be declared as Integer (2 bytes), and trip handles are declared as long integers.
- No functions in PC*Miler Connect use variants, or native Basic strings.
- All arguments must be declared to be passed with the modifier ByVal. This is especially true for any arguments that accept strings.
- String arguments that are modified by PC*Miler Connect must have their space declared beforehand. PC*Miler Connect does not dynamically resize Basic strings. For example, to get the text of error string #101, do either of the following:
Dim bytes As Integer
Dim buffer As String * 50
Dim buff2 As String
bytes = PCMSGetErrorString(101, buffer, 50)
buff2 = String(40, Chr(0))
bytes = PCMSGetErrorString(101, buff2, Len(buff2))
Strings Utility
PCMSStrLen returns the length in bytes of a ‘C’ string. This is simply a cover of the ‘C’ strlen routine.
Using PC*Miler Connect with Web Applications Running Under Internet Information Services
A working sample code with solution file is in the ...\ALK Technologies\PCMILERXX\Connect
folder. The solution file is called pcmdotnet.sln. You should be able to open it in Visual Studio 2003 or higher and build and run this sample application.
- Sample VB.Net source code is in the
...\ALK Technologies\PCMILERXX\Connect\VB.NET
folder. The file is called testconnect.vb. - Sample C# source code is in the
...\ALK Technologies\PCMILERXX\Connect\Csharp
folder. The file is called testconnect.cs. - Sample C# source code with external API function declarations is in the
...\ALK Technologies\PCMILER31\Connect\PCMDLLINT
folder. The file is called PCMDLL.cs. This file is compiled and builds a wrapper dll called pcmdllint.dll which can be used by C# applications or VB.NET applications. A programmer can add more of the PC*Miler Connect functions to this wrapper following the data type rules below.
The data type mapping rules
- Use int or integer for longs and shorts. NOTE: The TRIPID should be declared as Int or Integer.
- Use StringBuilder for returned strings.
- Use ref or ByRef for long/int/short pointers to returned pointers.
Configuring/Administrating Internet Information Services
If your application is locked into 64 bit mode, only the 64 bit versions of the PC*Miler dlls will work with it. If your application is 32 bit, follow the steps below to get things running with our 32-bit PC*Miler dlls.
- Under IIS 7, configure the application pools to run in “Classic Mode” win 32, and configure the application pools to run .NET 2.0 version.
- If your .NET application was created using MS Visual Studio, you’ll need to build the application using the x86 target output option. (This is under the Build Properties tab, the Platform Target pull-down option should be x86 which is another name for 32 bit.)
- If your application is 64 bit then our interop wrapper dll should be created with the Platform Target pull-down option set to x64 or Any CPU. If the platform is 64 bit, your application is 64 bit, and ALK’s 64 bit dlls are installed in the correct folders, then having the platform set to Any CPU or x64 should work.