Yeah; I didn't see is a wchar; so is a 256*2 array; [MarshalAs(UnmanagedType.ByValArray, SizeConst=512)] public byte[] wszTitle;
or [MarshalAs(UnmanagedType.ByValArray, SizeConst=512)] public char[] wszTitle; And put the 0 wchar_t to mark the end of the string, after you fill the array; > -----Original Message----- > From: dotnet discussion [mailto:[EMAIL PROTECTED]]On Behalf Of > Andreas Häber > Sent: Monday, May 20, 2002 4:40 PM > To: [EMAIL PROTECTED] > Subject: Re: [DOTNET] How to marshal WChar[256] in COM interop? > > > Thanks, but none of them worked :( > > Seems like the type needs to be String, otherwise the deskband won't show > the 'Show title' option on the context-menu you get when > right-clicking the > deskband. > > Andreas Häber > > ----- Original Message ----- > From: "Dumitru Sbenghe" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Monday, May 20, 2002 3:32 PM > Subject: Re: [DOTNET] How to marshal WChar[256] in COM interop? > > > > Is clear why your struct definition is not good; a LPWStr is a > pointer to > > wchar_t which have 4 bytes in the struct; > > Your WCHAR wszTitle[256] have 512 bytes in the struct, so you > will make a > > mess in the struct marshaling; > > > > I guess this field definition will work without problems > > > > [MarshalAs(UnmanagedType.ByValArray, SizeConst=256)] > > public byte[] wszTitle; > > > > or > > > > [MarshalAs(UnmanagedType.ByValArray, SizeConst=256)] > > public char[] wszTitle; > > > > Dumitru Sbenghe > > http://www.dsbenghe.home.ro/ > > > > > Hey, > > > I'm having problems getting my DeskBand shell extension display it's > name > > > properly. This is happening in the IDeskBand::GetBandInfo method. > > > > > > It seems like the error is when marshalling the string. > > > > > > The DESKBANDINFO structure which is used to have this information > > > is defined > > > in ShObjIdl.idl as: > > > typedef struct { > > > DWORD dwMask; > > > POINTL ptMinSize; > > > POINTL ptMaxSize; > > > POINTL ptIntegral; > > > POINTL ptActual; > > > WCHAR wszTitle[256]; > > > DWORD dwModeFlags; > > > COLORREF crBkgnd; > > > } DESKBANDINFO; > > > > > > This would've been simple if it was LPWSTR lpszTitle; or > something like > > > that, but I can't get that WCHAR correct. > > > > > > This is how I've defined the same structure in my code, using C#: > > > [StructLayout (LayoutKind.Sequential, CharSet=CharSet.Unicode)] > > > public struct DeskBandInfo > > > { > > > public Int32 dwMask; > > > public POINTL ptMinSize; > > > public POINTL ptMaxSize; > > > public POINTL ptIntegral; > > > public POINTL ptActual; > > > [MarshalAs(UnmanagedType.LPWStr, SizeConst=256)] public > > > String wszTitle; > > > public Int32 dwModeFlags; > > > public Int32 crBkgnd; > > > } > > > > > > POINTL is a structure I've defined too, but that's not important > > > right now. > > > I've also tried using an array of Char as the wszTitle, but the shell > > > doesn't like that very much :( and won't even call my > > > IDeskBand::GetBandInfo > > > method... > > > > > > So.. does anybody see what I'm doing wrong here? Right now I > only get to > > > small rectangles as the title of my deskband, which isn't correct. > > > > > > Andreas Häber > > > > > > You can read messages from the DOTNET archive, unsubscribe > from DOTNET, > or > > > subscribe to other DevelopMentor lists at http://discuss.develop.com. > > > > You can read messages from the DOTNET archive, unsubscribe from > DOTNET, or > > subscribe to other DevelopMentor lists at http://discuss.develop.com. > > > > > > > > You can read messages from the DOTNET archive, unsubscribe from DOTNET, or > subscribe to other DevelopMentor lists at http://discuss.develop.com. You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.