0
문자열 형식을 BSTR * 형식으로 마샬링하는 방법을 궁금합니다. 그냥 정교의 C++ 구조는 다음과 같다 :BSTR * 형식을 정의하고 마샬링하는 방법
struct MyStruct
{
BSTR* string;
int a;
}
내가 C#을 측면에서 새로운 sturct를 정의 할 필요가, 난 두 문자열 []와 IntPtr입니다 []을하지만 성공을 마련하지 않았다 시도 .
도움 주셔서 감사합니다.
편집 : C++ 구조 :
struct HTTPTEXTRENDERERFILTERINFO {
enum { UTC, GMT } eTimestamp;
BOOL bEnableCCIngest;
LONG lQueueSizeTreshold;
LONG lSendTimeTreshold;
BYTE btBroadcastUrlCount;
BSTR* pbstrBroadcastUrls;
LONG lInputPinsNum;
};
와 함수의 프로토 타입 :
HRESULT HTTPTextRendererFilter::SetConfig(IN const HTTPTEXTRENDERERFILTERINFO& Config)
C#을 구조 :
[StructLayout (LayoutKind.Sequential, CharSet는 = CharSet.Unicode)] public struct HttpTextRenderFilterInfo { 공개 열거 형 TimestampType : int {UTC, GMT};
public TimestampType Timestamp; public int EnableCCIngest; public int QueueSizeTreshold; public int SendTimeTreshold; public byte BroadcastUrlCount; [MarshalAs(UnmanagedType.BStr)] public string pbstrBroadcastUrls; public int lInputPinsNum; };
프로토 타입 :
[PreserveSig]
int SetConfig([In] ref HttpTextRenderFilterInfo config);
덕분에, 내가해야 할 다른 무엇은 무엇입니까? Marshal.stringToPtr 등등 ..? –
특별한 것은 필요 없습니다. – logicnp
전체 구조체가 C#에서 C++ 측으로 전달되면 손상된 의미있는 값이 없습니다. 원래의 게시물을 편집하여 사례를 보여줍니다. –