TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Z
NA
1
0
Managed Callback from WinAPI: Problem with unicode string
Apr 3 2006 5:03 PM
------------------------------------------------ Help, how do you post code on this forum? ------------------------------------------------ Im calling a native WinAPI method with a callback function that is implemented in C#. The callback works but the unicode strings passed to the callback are not properly converted. If i print them i only get the first letter of the string. I have had the same problem on the C side when accidently treating a unicode string as an ANSI one. The relevant snippet of code is shown below: (details of the EnumPwrSchemes function can be found here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/power/base/enumpwrschemes.asp) [DllImport("PowrProf.dll")] private static extern bool EnumPwrSchemes(callback_delegate lpfnPwrSchemesEnumProc, uint LPARAM); private delegate bool callback_delegate(uint uiIndex, UInt32 dwName, String sName, UInt32 dwDesc, String sDesc, uint pp, uint lParam); private bool callback(uint uiIndex, UInt32 dwName, String sName, UInt32 dwDesc, String sDesc, uint pp, uint lParam) { Console.WriteLine(dwName + " , " + sName + " : " + sDesc);
Reply
Answers (
0
)
Changing config infor in a program during the installation
More dynamic debugging output