A question about GetPrivateProfileString

G

Guest

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
 
L

Luke Meyers

海风 said:
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
 
G

Guest

Luke said:
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?
 
R

Rolf Magnus

海风 said:
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.
 
R

Robbie Hatley

A-Person-With-A-Unicode-Name said:
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/
 
B

BigBrian

海风 said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top