int PBORCA_LibraryDirectory ( HPBORCA hORCASession, LPSTR lpszLibName, LPSTR lpszLibComments, int iCmntsBuffSize, PBORCA_LISTPROC pListProc, LPVOID pUserData );
参数说明
hORCASession Handle to previously established ORCA session
lpszLibName Pointer to a string whose value is the filename of the library for which you want directory information
lpszLibComments Pointer to a buffer in which ORCA will put comments stored with the library
iCmntsBuffSize Size of the buffer pointed to by lpszLibComments
pListProc Pointer to the PBORCA_LibraryDirectory callback function. The callback function is called for each entry in the library The information ORCA passes to the callback function is entry name, comments, size of entry, and modification time, stored in a structure of type PBORCA_DIRENTRY
pUserData Pointer to user data to be passed to the PBORCA_LibraryDirectory callback function The user data typically includes the buffer or a pointer to the buffer in which the callback function formats the directory information as well as information about the size of the buffer
参数说明 PPBORCA_DIRENTRY Pointer to the structure PBORCA_DIRENTRY, described next
LPVOID Long pointer to user data 结构体PBORCA_DIRENTRY structure如下 typedef struct pborca_direntry { CHAR szComments[PBORCA_MAXCOMMENT + 1]; LONG lCreateTime; LONG lEntrySize; LPSTR lpszEntryName; PBORCA_TYPE otEntryType;} PBORCA_DIRENTRY, FAR *PPBORCA_DIRENTRY;
函数 [DllImport("pborc90.dll", EntryPoint = "PBORCA_LibraryDirectory")] public static extern int EntryList(uint sessionId, string libName, StringBuilder libComents, int comentSize, dele_test treatFunc, uint UserData);
两个结构体 [StructLayout(LayoutKind.Sequential)] public struct ORCA_UserDataInfo { // public char[] entryInfo; // Buffer for entry info public uint dwCallCount; // # of entries in lib public uint dwBufferSize; // size of buffer public uint dwBufferOffset; // current offset in buffer } [StructLayout(LayoutKind.Sequential)] public struct PBORCA_DIRENTRY { public char[] szComments; // Buffer for entry info public int lCreateTime; // # of entries in lib public int lEntrySize; // size of buffer public string lpszEntryName; // current offset in buffer public uint otEntryType;
}
委托 public delegate void dele_test(PBORCA_DIRENTRY entryInfo, uint udInfo);
[StructLayout(LayoutKind.Sequential)] public struct ORCA_UserDataInfo { // public char[] entryInfo; // Buffer for entry info public uint dwCallCount; // # of entries in lib public uint dwBufferSize; // size of buffer public uint dwBufferOffset; // current offset in buffer } [StructLayout(LayoutKind.Sequential)] public struct PBORCA_DIRENTRY { public char[] szComments; // Buffer for entry info public int lCreateTime; // # of entries in lib public int lEntrySize; // size of buffer public string lpszEntryName; // current offset in buffer public uint otEntryType;
publicstruct PBORCA_DIRENTRY
{
[MarshalAs(SizeConst=50)]
publicchar[] szComments; // Buffer for entry info publicint lCreateTime; // # of entries in lib publicint lEntrySize; // size of buffer publicstring lpszEntryName; // current offset in buffer publicuint otEntryType;
}
Error 2 'System.Runtime.InteropServices.MarshalAsAttribute' does not contain a constructor that takes '0' arguments E:\My Document\Visual Studio 2008\Projects\PBORCATry\PBORCATry\Program.cs 160 10 PBORCATry
Pointer to user data to be passed to the PBORCA_LibraryDirectory callback function The user data typically includes the buffer or a pointer to the buffer in which the callback function formats the directory information as well as information about the size of the buffer
typedef struct ORCA_UserDataInfo { LPSTR lpszBuffer; // Buffer for entry info DWORD dwCallCount; // # of entries in lib DWORD dwBufferSize; // size of buffer DWORD dwBufferOffset; // current offset in buffer } ORCA_USERDATAINFO, FAR *PORCA_USERDATAINFO;
这是例子中的结构体的定义 我转成了 [StructLayout(LayoutKind.Sequential)] public struct ORCA_UserDataInfo {
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 200)] public byte[] entryInfo; // Buffer for entry info public uint dwCallCount; // # of entries in lib public uint dwBufferSize; // size of buffer public uint dwBufferOffset; // current offset in buffer }