Click here to Skip to main content
12,893,816 members (50,658 online)
Click here to Skip to main content
Add your own
alternative version

Stats

24.3K views
508 downloads
14 bookmarked
Posted 25 Sep 2006

A Class of Accessing inifile in UNICODE

, 25 Sep 2006 CPOL
Rate this:
Please Sign up or sign in to vote.
The Win API cannot access inifile in UNICODE, sometimes, we may want to add some wide characters into INI file, so I wrote a class to access INI file in UNICODE

Introduction

The Windows API of accessing INI file cannot support UNICODE FILE, for instance, if someone wants to write a Chinese string into an INIFILE and read it in a Japanese system, he will not get the correct string.

So, I wrote a class to access INIFILE in UNICODE. You can use it as using Win API. This class provides such interfaces:

static INT GetPrivateProfileInt(
  LPCWSTR lpAppName,  	// address of section name

  LPCWSTR lpKeyName,  	// address of key name

  INT nDefault,       	// return value if key name is not found

  LPCWSTR lpFileName  	// address of initialization filename

  );

static DWORD GetPrivateProfileSection(
  LPCWSTR lpAppName,       	// address of section name

  LPWSTR lpReturnedString,	// address of return buffer

  DWORD nSize,            	// size of return buffer

  LPCWSTR lpFileName      	// address of initialization filename

  );

static DWORD GetPrivateProfileSectionNames(
  LPWSTR lpszReturnBuffer,	// address of return buffer

  DWORD nSize,            	// size of return buffer

  LPCWSTR lpFileName      	// address of initialization filename

  );

static DWORD GetPrivateProfileString(
  LPCWSTR lpAppName,        // points to section name

  LPCWSTR lpKeyName,        // points to key name

  LPCWSTR lpDefault,        // points to default string

  LPWSTR lpReturnedString,  // points to destination buffer

  DWORD nSize,              // size of destination buffer

  LPCWSTR lpFileName        // points to initialization filename

  );

static BOOL WritePrivateProfileSection(
  LPCWSTR lpAppName,  	// pointer to string with section name

  LPCWSTR lpString,   	// pointer to string with data

  LPCWSTR lpFileName  	// pointer to string with filename

  );

static BOOL WritePrivateProfileString(
  LPCWSTR lpAppName,  	// pointer to section name

  LPCWSTR lpKeyName,  	// pointer to key name

  LPCWSTR lpString,   	// pointer to string to add

  LPCWSTR lpFileName  	// pointer to initialization filename

  );

static BOOL WritePrivateProfileInt(
  LPCWSTR lpAppName,  	// pointer to section name

  LPCWSTR lpKeyName,  	// pointer to key name

  INT nValue,   		// pointer to string to add

  LPCWSTR lpFileName  	// pointer to initialization filename

  );

History

  • 26th September, 2006: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

aaa_xxx_aaa
Web Developer
China China
No Biography provided

You may also be interested in...

Comments and Discussions

 
Generalthe API can do this for you Pin
umeca7413-Apr-10 6:14
memberumeca7413-Apr-10 6:14 
GeneralRe: the API can do this for you Pin
andreaplanet5-Feb-12 7:04
memberandreaplanet5-Feb-12 7:04 
GeneralFirst "class"! Pin
barryem9-Apr-08 13:55
memberbarryem9-Apr-08 13:55 
GeneralGreat work Pin
sirnowy10-Sep-07 9:28
membersirnowy10-Sep-07 9:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170424.1 | Last Updated 26 Sep 2006
Article Copyright 2006 by aaa_xxx_aaa
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid