473,387 Members | 1,291 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

A question about GetPrivateProfileString


A question about GetPrivateProfileString
a section in a .ini file , for example
[server]
ip = 192.168.1.112
....

i want to get the ip value by using GetPrivateProfileString() function.
the code is :

char szBuffer[NAX_BUFFER_LEN];
szBuffer[0]=0;

if (::GetPrivateProfileString("GameServer1", "GameServerIp",\
NULL, szBuffer, sizeof(szBuffer), szPath)>0)
{
m_ip.SetWindowText(szBuffer);
}
i get it successfully.

however, when i modify the ip's value manually, the value returned by
GetPrivateProfileString() function is always less than 0 . Can you
tell me why?

thanks in advance

Jun 30 '06 #1
5 7629
海风 wrote:
A question about GetPrivateProfileString


What's that? It's certainly not part of standard C++, nor have you
provided a definition of it, so I assume you're asking about some
platform-specific API, in which case you're off-topic and need to read
the FAQ before posting, as is common courtesy for any newsgroup.

parashift.com/c++-faq-lite

Luke

Jun 30 '06 #2

Luke Meyers wrote:
What's that? It's certainly not part of standard C++, nor have you
provided a definition of it, so I assume you're asking about some
platform-specific API, in which case you're off-topic and need to read
the FAQ before posting, as is common courtesy for any newsgroup.

parashift.com/c++-faq-lite

Luke

ow that's a windows api. Maybe i posted on a wrong place. sorry.
but if you only manipulate the pure c++ without supporting of specific
platform.
what can you do?

Jun 30 '06 #3
海风 wrote:

Luke Meyers wrote:
What's that? It's certainly not part of standard C++, nor have you
provided a definition of it, so I assume you're asking about some
platform-specific API, in which case you're off-topic and need to read
the FAQ before posting, as is common courtesy for any newsgroup.

parashift.com/c++-faq-lite

Luke

ow that's a windows api. Maybe i posted on a wrong place. sorry.
but if you only manipulate the pure c++ without supporting of specific
platform.
what can you do?


Well, I don't know what GetPrivateProfileString does, but it seems to have
something to do with networking, which is not supported by standard C++.
Anyway, there are quite some newsgroups about Windows programming where you
can ask your question about GetPrivateProfileString.

Jun 30 '06 #4

A-Person-With-A-Unicode-Name wrote:
A question about GetPrivateProfileString
(snip stuff)
GetPrivateProfileString
(
"GameServer1",
"GameServerIp",
NULL,
szBuffer,
sizeof(szBuffer),
szPath

... when i modify the ip's value manually, the value returned by
GetPrivateProfileString() function is always less than 0 . Can you
tell me why?


That's strictly Microsoft Windows stuff. This is a C++ group, so this is
off-topic here. I'm setting followup to:

comp.os.ms-windows.programmer.win32

To learn more about "GetPrivateProfileString", highlight it in your source
and hit F1. That should launch your MSDN and set it to display info on this
function. (Assuming you're using Visual Studio and have MSDN installed.)

MSDN says that the third parameter is not allowed to be NULL, so you're
abusing the function. Provide a valid default string and see what happens.

For more info, ask in the group I mention above. Also, read MSDN. Also,
get Charles Petzold's book "Programming Windows".

--
Cheers,
Robbie Hatley
Tustin, CA, USA
lonewolfintj at pacbell dot net (put "[ciao]" in subject to bypass spam filter)
http://home.pacbell.net/earnur/

Jun 30 '06 #5

海风 wrote:
but if you only manipulate the pure c++ without supporting of specific
platform.
what can you do?


You can write standard c++ code that's portable and not dependent on
platform specific libraries, especially ones which are tied to a single
company who's goal is to control the world.

-Brian

Jun 30 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: eScrewDotCom | last post by:
eScrew Welcome to eScrew! eScrew is eScrew and this is eScrew story. eScrew will tell you eScrew story if you promise eScrew to consider eScrew story as joke. eScrew story is very funny. eScrew...
4
by: Mark Hayworth | last post by:
Randy: I too am having the problem that this other guy/girl had. I put in the proper API declarations and arguments for GetPrivateProfileString yet it doesn't return the correct stuff. It always...
16
by: cyranoVR | last post by:
This is the approach I used to automate printing of Microsoft Access reports to PDF format i.e. unattended and without annoying "Save As..." dialogs, and - more importantly - without having to use...
3
by: Eifel-benz | last post by:
I'm working the first days with Visual C#.net. So most of you think these questions are really easy. 1. How can I read out the windows-account? 2. How can I read datas from an INI-file? A...
1
by: Germic | last post by:
Does C# has an equivalent of the 'C' GetPrivateProfileString? or is the only way to get similar features to read from an INI file is to do a DllImport on Kernel32.dll? Thanks
5
by: L | last post by:
static extern uint GetPrivateProfileString( string lpAppName, string lpKeyName, string lpDefault, StringBuilder lpReturnedString, uint nSize, string lpFileName); Interoping...
2
by: Nhan | last post by:
Hi, I am trying to use the function GetPrivateProfileString as following: public static extern Int32 GetPrivateProfileString(string lpAppName, string lpKeyName, string lpDefault, string...
1
by: thiago777 | last post by:
Is there a better way of accomplishing this ?: http://msdn2.microsoft.com/en-us/library/ms724353.aspx I have some program settings which should be easily editable by the user (really like in a...
6
by: alag20 | last post by:
Hi Guys, I need some urgent help with this as I am becoming clueless now. I have 2 DllImport as below from Kernel32 private static extern int GetPrivateProfileString(string section, int key,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.