Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Using WritePrivateProfileStringW

$
0
0

Hi

I searched the internet to find out how to use WritePrivateProfileStringW as I wanted to write data to a unicode INI file just like I do in Visual C++.

This is the code:

        [DllImport("KERNEL32.DLL", EntryPoint = "WritePrivateProfileStringW",
                   SetLastError = true,
                   CharSet = CharSet.Unicode, ExactSpelling = true,
                   CallingConvention = CallingConvention.StdCall)]
        private static extern int WritePrivateProfileStringW(
                    string lpAppName,
                    string lpKeyName,
                    string lpString,
                    string lpFilename);

But when I open the INi file in NotePad and go to save it I find it is in ANSI format.

If I empty the file contents and save as UNICODE and run my routine again the fiel remains unicode. So how do I start off automatically with a unicode file?

Andrew


Viewing all articles
Browse latest Browse all 31927

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>