P4VB - COM Interface to Perforce C++ API on Windows

p4vb is contributed by Robert Cowham of Vaccaperna Systems Ltd.

See the paper I presented at the Perforce User Conference in 2001: Adventures in API Land for an overview of the API and how I use it.

Compiler

This COM DLL has been built with MS VC++ 6.0 (SP5). Future versions will be built with VC++ 7.0.

Use either of the project settings:

Interface

The IDL definition is:

[
entry("p4run"),
helpstring("runs a p4 command 'cmd' returning values in 2 output arrays"),
]
Long p4run([in] BSTR cmd,
	[out] ArrayString infoArray,
	[out] ArrayString errorArray,
	[out] BSTR * TextFileName,
	[out] BSTR * BinaryFileName);

As an example of using it:

Dim p4cmd As String
Dim result As Long
Dim TextArr() As String
Dim InfoArr() As String
Dim ErrorArr() As String
Dim TextFileName As String
Dim BinaryFileName As String

' Need to initialise as otherwise VB kindly passes in a NULL pointer.
TextFileName = "temp"
BinaryFileName = "temp"
p4cmd = "print " & Chr(34) & DocPathname & "#" & ver & Chr(34)
result = p4run(p4cmd, InfoArr, ErrorArr, TextFileName, BinaryFileName)

This will print the results of the file into the temporary file in either TextFileName or BinaryFileName from which it can be further processed.

Other Perforce commands might not result in any file output, but just strings in InfoArr() or ErrorArr().

Other examples to follow...

Top