By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,804 Members | 1,634 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,804 IT Pros & Developers. It's quick & easy.

A question about GetPrivateProfileString

P: n/a

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
Share this Question
Share on Google+
5 Replies


P: n/a
海风 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

P: n/a

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

P: n/a
海风 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

P: n/a

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

P: n/a

海风 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 discussion thread is closed

Replies have been disabled for this discussion.