Click here to Skip to main content
Click here to Skip to main content

A Class of Accessing inifile in UNICODE

, 25 Sep 2006
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

Comments and Discussions

 
Generalthe API can do this for you Pinmemberumeca7413-Apr-10 6:14 
GeneralRe: the API can do this for you Pinmemberandreaplanet5-Feb-12 7:04 
GeneralFirst "class"! Pinmemberbarryem9-Apr-08 13:55 
GeneralGreat work Pinmembersirnowy10-Sep-07 9:28 

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

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

| Advertise | Privacy | Mobile
Web02 | 2.8.140821.2 | Last Updated 26 Sep 2006
Article Copyright 2006 by aaa_xxx_aaa
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid