Hi Roger, cmsGetProfileInfo has to be called twice: The first time you pass 0 (Buffer and BufferSize) and cmsGetProfileInfo is calculating how much memory you have to allocate. Then you allocate the memory, and call it a second time (passing a pointer to the buffer, and the calculated size in BufferSize). After you're done it's your last job to free this memory.
Note: Language code and country code are char, i.e. not unicode. imho they should be marshaled as UnmanagedType.LPStr or UnmanagedType.AnsiBStr Edgar Am 10.07.2016 um 23:42 schrieb Roger Breton: > Looks like I'm becoming a "regular contributor" to this list... > > I don't find it easy to figure out C# signature for all the lcms C > functions... > > The original C function looks like this : > > cmsUInt32Number cmsGetProfileInfo( > cmsHPROFILE hProfile, > cmsInfoType Info, > const char LanguageCode[3], > const char CountryCode[3], > wchar_t* Buffer, > cmsUInt32Number BufferSize); > > The "best" DLLImport I could come up with, in C# is this : > > [DllImport(@lcms2Path, CharSet = CharSet.Unicode)] > public extern static UInt32 cmsGetProfileInfo( > IntPtr hProfile, > int InfoType, > [MarshalAs(UnmanagedType.BStr)]string languageCode, // > UnmanagedType.BStr = A COM-style BSTR with a prefixed length and Unicode > characters. > [MarshalAs(UnmanagedType.BStr)]string countryCode, > [Out, MarshalAsAttribute(UnmanagedType.LPWStr)] > StringBuilder buffer, > UInt32 bufferSize); > > And, in code, I call the function like this : > > StringBuilder Buffer = new StringBuilder(255); > UInt32 Buffer=0; > UInt32 descSize; > descSize = cmsGetProfileInfo(hSource, 0, "en", "US", Buffer, 0); > > When I execute the function, descSize = 0 and Buffer is empty... > > ---- > > I also tried this Import statement : > > [DllImport(@lcms2Path, CharSet = CharSet.Unicode)] > public extern static UInt32 cmsGetProfileInfo( > IntPtr hProfile, > [In] int InfoType, > [In] string languageCode, // UnmanagedType.BStr = A > COM-style BSTR with a prefixed length and Unicode characters. > [In] string countryCode, > [Out] StringBuilder buffer, > [Out] UInt32 bufferSize); > > But don't get any better? > > For curiosity, I also tried the following in C : > > wchar_t* Buffer; > cmsUInt32Number BufferSize, DescSize; > BufferSize = 0; > > Buffer = NULL; > > cmsInfoType Info; > > Info = cmsInfoDescription; > > DescSize = cmsGetProfileInfo(rgbProfile, Info, "en", "US", Buffer, > BufferSize); > > When I execute the function, DescSize = 20 but Buffer is null and BufferSize > = 0. > > / Roger > > > ------------------------------------------------------------------------------ > Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San > Francisco, CA to explore cutting-edge tech and listen to tech luminaries > present their vision of the future. This family event has something for > everyone, including kids. Get more information and register today. > http://sdm.link/attshape > _______________________________________________ > Lcms-user mailing list > Lcms-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/lcms-user > -- lakeBits Inh. Edgar Loser Haydnstr. 25 78464 Konstanz Tel 0049 7531 5844154 0 Fax 0049 7531 5844154 9 http://www.colymp.com/ mailto:lo...@colymp.com ------------------------------------------------------------------------------ Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San Francisco, CA to explore cutting-edge tech and listen to tech luminaries present their vision of the future. This family event has something for everyone, including kids. Get more information and register today. http://sdm.link/attshape _______________________________________________ Lcms-user mailing list Lcms-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lcms-user