我似乎无法正确传递正确的论据。我得到了
“无效的名称解析缓冲区大小”错误
Lotus注释dname.h中的函数
STATUS LNPUBLIC DNParse(
DWORD Flags,
const char far *TemplateName,
const char far *InName,
DN_COMPONENTS far *Comp,
WORD CompSize);
下面的结构
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct DN_COMPONENTS
{
public int Flags;
[MarshalAs(UnmanagedType.LPWStr)]
public string C;
public short OLength;
[MarshalAs(UnmanagedType.LPWStr)]
public string O;
[MarshalAs(UnmanagedType.LPWStr)]
public string CN;
};
C#
以下是我的尝试
Status sts = 0;
StringBuilder szServer = new StringBuilder(names.MAXUSERNAME);
string notUsedString = null;
DWORD notUsed = 0;
dname.DN_COMPONENTS xdDC = new DN_COMPONENTS();
sts = nnotesDLL.SECKFMGetUserName(szServer);
//IntPtr structPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(dname.DN_COMPONENTS)));
//UInt16 num = Convert.ToUInt16(Marshal.SizeOf(structPtr));
//WORD num = Convert.ToUInt16(Marshal.SizeOf(structPtr));
int num = Marshal.SizeOf(typeof(DN_COMPONENTS));
IntPtr structPtr = Marshal.AllocCoTaskMem(num);
sts = nnotesDLL.DNParse(notUsed, notUsedString, szServer, structPtr, (UInt32)num);
this.xdDC = (dname.DN_COMPONENTS)Marshal.PtrToStructure(structPtr, typeof(dname.DN_COMPONENTS));
xdDC.CN = Decode(Marshal.ReadIntPtr(structPtr), ushort.MaxValue);
///CN=SomeFirstName SomeLastName/OU=Corp/O=test
我正在寻找“SomeFirstName SomeLastName”
[DllImport("nnotes.DLL", CallingConvention = CallingConvention.StdCall)]
public unsafe static extern Status DNParse(DWORD notUsed, string notUsedString, StringBuilder InName, IntPtr structPtr, UInt32 structPtrSizeOf);
我已经通过ref尝试所有变体,参考struct,更改为string,int,uint Nothing !!!
...帮助
我要找的是CN = SomeFirstName SomeLastName / OU = Corp / O = test
答案 0 :(得分:0)
我可以看到的问题: