// ************** Copyright ************************* // Alphatronics Virtual Port Monitor Version 3.2o // Application Programmers Interface Reference // (C) 2002, Alphatronics, Inc. // ************** Disclaimer ************************ // This documentation is provided as-is. Alphatronics, Inc // cannot be held responsible for the use or misuse of // this material. // *************** Purpose ************************** // The purpose of this document is to provide copy and // paste declarations for the 2 functions exported by // the Virtual Port Monitor Dialog DLL, SetVirtualPort // and GetVirtualPort. It may seem that the only thing being // done by these functions is setting registry values, but there // is more to it than that. Windows 9x does allow registry keys // located in the CurrentControlSet\Control\Print section // to be modified, but NT may not, depending on the permissions // granted to the application/user. Also, NT will not recognize // ports that were not introduced by the AddPort() function, // which normally brings up a dialog. These functions are // designed to overcome these limitations while providing // full configuration capabilities to the programmer. // *********** Programmer Notes ******************** // The two exported functions are located in AVPDlg.dll. // Pass a pointer to a TVirtualPort structure // which contains pointers to the various strings // that will be stored into or retrieved from // the registry. All values are strings. When getting // data, allocate BufferSize bytes for each non-null // pointer within the TVirtualPort structure. Size and // PortName are required or the function will fail. // Upon setting data, the port is ready for immediate // use. For NT, etc., You can set the UserName and // Password, but you cannot get them, no matter what // security level you are running at. There are 4 basic // reasons these functions might fail. A Null VirtualPort // structure pointer, A Null PortName, A blank PortName, // or an Exception caused by non-null, but invalid pointers. // These functions do not allocate or free memory for you, // so these are all "your" pointers and memory. // You can choose which members to set by passing valid pointers // to items you want to change. If members of the structure // are null, they will be left alone on a "configure", but will // be set to default values on a "create". // These are ansi only functions. To delete ports // use the DeletePort Windows routine. // Delphi Constants and types Const VPConfigDLL = 'AVPDLG'; FH_AutoFile = 0; // File Handling FH_NoFile = 1; // Application only FH_LogFile = 2; // Append AF_Title = 0; // NameOptions AF_DateTime = 1; // 18 Digit timestamp AF_TitleDateTime = 2; AF_DateTimeTitle = 3; AF_UserNameDateTime = 4; AF_DateTimeUserName = 5; AF_ComputerNameDateTime = 6; AF_DateTimeComputerName = 7; AF_PortDateTime = 8; AF_DateTimePort = 9; LO_Day = 0; // LogOptions LO_Month = 1; LO_DayN = 2; // Numerical LO_MonthN = 3; LO_YearN = 4; LO_File = 5; VP_False = 0; // Obvious? VP_True = 1; VP_SW_Normal = 0; VP_SW_Minimized = 1; VP_SW_Maximized = 2; Type PVirtualPort = ^TVirtualPort; TVirtualPort = Record Size : Cardinal; // Required; total bytes in this structure PortName : PChar; // Required Application : PChar; // you can use %env vars% or %1 DirectToFile : PChar; // 0 or 1 DragDrop : PChar; // 0 or 1 Extension : PChar; // Up to 3 characters FileHandling : PChar; // FH_ Constants Forwarding : PChar; // Port List, comma separated LogName : PChar; // Filename only LogOptions : PChar; // LO_ Constants NameOptions : PChar; // AF_ Constants Port : PChar; // Output path ShowWindow : PChar; // 0 Normal; 1 Minimized; 2 Maximized UserDir : PChar; // 0 or 1 Spooling : PChar; // Printer List, comma separated UserName : PChar; // NT Only; Not returned by Get... Password : PChar; // NT Only; Not returned by Get... Domain : PChar; // NT Only End; TSetVirtualPortProc = Function(VP : PVirtualPort) : LongBool; StdCall; // Pass a pointer to a TVirtualPort Structure TGetVirtualPortProc = Function(VP : PVirtualPort; BufferSize : Cardinal) : LongBool; StdCall; // Pass a pointer to a TVirtualPort Structure and the // Per Member buffer size. ie; Each string can hold 1024 bytes // C Constants and Declarations #define VPConfigDLL TEXT("AVPDLG") #define FH_AutoFile 0x00000000 #define FH_NoFile 0x00000001 #define FH_LogFile 0x00000002 #define AF_Title 0x00000000 #define AF_DateTime 0x00000001 #define AF_TitleDateTime 0x00000002 #define AF_DateTimeTitle 0x00000003 #define AF_UserNameDateTime 0x00000004 #define AF_DateTimeUserName 0x00000005 #define AF_ComputerNameDateTime 0x00000006 #define AF_DateTimeComputerName 0x00000007 #define AF_PortDateTime 0x00000008 #define AF_DateTimePort 0x00000009 #define LO_Day 0x00000000 #define LO_Month 0x00000001 #define LO_DayN 0x00000002 #define LO_MonthN 0x00000003 #define LO_YearN 0x00000004 #define LO_File 0x00000005 #define VP_False 0x00000000 #define VP_True 0x00000001 #define VP_SW_Normal 0x00000000 #define VP_SW_Minimized 0x00000001 #define VP_SW_Maximized 0x00000002 typedef struct TVirtualPort { DWORD Size // Required; total bytes in this structure LPSTR PortName // Required LPSTR Application // you can use %env vars% or %1 LPSTR DirectToFile // 0 or 1 LPSTR DragDrop // 0 or 1 LPSTR Extension // Up to 3 characters LPSTR FileHandling // FH_ Constants LPSTR Forwarding // Port List, comma separated LPSTR LogName // Filename only LPSTR LogOptions // LO_ Constants LPSTR NameOptions // AF_ Constants LPSTR Port // Output path LPSTR ShowWindow // 0 Normal; 1 Minimized; 2 Maximized LPSTR UserDir // 0 or 1 LPSTR Spooling // Printer List, comma separated LPSTR UserName // NT Only; Not returned by Get... LPSTR Password // NT Only; Not returned by Get... LPSTR Domain // NT Only } TVirtualPort, *PVirtualPort; BOOL // Returns DWORD size Boolean WINAPI // Stack, not register SetVirtualPort(PVirtualPort VirtualPort); // Pass a pointer to a TVirtualPort Structure BOOL // Returns DWORD size Boolean WINAPI // Stack, not register GetVirtualPort(PVirtualPort VirtualPort, DWORD BufferSize); // Pass a pointer to a TVirtualPort Structure and the // Per Member buffer size. ie; Each string can hold 1024 bytes