Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 04-06-2006, 06:50 PM   #1 (permalink)
RPG
 
Newb Techie

Join Date: Oct 2005

Posts: 2

RPG

Send a message via AIM to RPG
Question C++ Data Pointer Question

Hi,

I am a self-taught C++er. Since I taught myself, I will admin it wasn't the best education, but it got the job done for simple C++ patches to some of my favorite open-source programs.

Recently, I decided to take a crash-course in making Windows Forms with the Windows Form maker embedded in Microsoft Visual Studio .NET 2003. My goal was to make a program that allowed users to send "net send" messages to other people. Now before you say this is a stupid idea, consider this:
  • Some of the computers I want to use this on have the command prompt disabled
  • net send is a great Windows-only feature, and since I'm using a Windows Form, I wouldn't be tempted to port this to another OS (I like perfection )

I have a function that gathers a list of names of computers on the local network (LAN), using the .NET API function NetServerEnum(...). Out of it I extracted the actual names of the network computers, which are sent to this function:

Code:
std::string print_si(SERVER_INFO_101 *pSI){
	printf("%-16.16S", pSI->sv101_name);
	//pSI->sv101_name is type LPWSTR _SERVER_INFO_101::sv101_name

	return std::string(pSI->sv101_name);
}
Now, I half-copied this function from a tutorial on NetServerEnum. The printf() line was inserted there by the original author, and that works perfectly, returning the server name -- but to the command line. My method, which is shown on the last line (return), is MY shoddy attempt at converting pSI to a std::string. However, my method only gives me the first letter of each domain name on the network. I would like it to return the entire name. The first example works great-- if it didn't' dump to stdout.

I need a way to convert pSI to a full length domain name contained in an std::string for use later. How would I do that?

If you need more of the program I can give it to you.
RPG is offline  
Old 04-06-2006, 06:52 PM   #2 (permalink)
 
Ultra Techie

Join Date: Jul 2005

Posts: 530

TheHeadFL

Send a message via AIM to TheHeadFL
Default

Maybe use sprintf function? Print to a string instead of stdout?

I dunno, I never use std::string. If I was doing Windows Forms and .NET I'd use the .NET String classes.
__________________
Desktop machine: 2 x Opteron 246, Asus K8N-DL, 2GB PC3200 ECC Reg., XFX GeForce 6600GT, 74gb WD Raptor, 2 x 19\" LCDs, Windows XP x64
Server machine: Intel P4 3.0GHz 2MB EM64T, ECS i865pe, 1GB PC3200, 36gb WD Raptor, Windows Server 2003
Laptop: Dell Inspiron 9100 (Intel P4 3.2GHz 1MB Prescott, i865pe, 512MB PC3200, Mobility Radeon 9700, DVD+R/DL Burner), Windows XP
Linux: P3 450Mhz, 386MB ram, Slackware 10.1 (Running mySQL/Apache)
TheHeadFL is offline  
Old 04-06-2006, 08:57 PM   #3 (permalink)
RPG
 
Newb Techie

Join Date: Oct 2005

Posts: 2

RPG

Send a message via AIM to RPG
Default

Wow, thanks man! Since I never got that formal C++ education I didn't know such a function like sprintf existed. Greatly appreciated! I'll have a link to the program when I finish adding this new function.
RPG is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On