|
Hai Friends,
How can i get the IP addrees of the current system.
Plase anyone give me a step by step procedure
|
|
|
|
|
Hello,
I've done this before using windows sockets.
I don't know if it's the best way, but it definitely works:
char szHostName[400];
struct hostent *hostinfo = NULL;
IN_ADDR addr;
char szIP[16]; // "xxx.xxx.xxx.xxx\0"
ULONG ulIP = 0;
// get the dns name as a string
gethostname(szHostName, 400);
// get the host info (contains ip address)
hostinfo = gethostbyname(szHostName);
if(hostinfo == NULL)
{
DWORD dwError = WSAGetLastError();
// handle the error
}
else
{
// get the ip as ULONG
ulIP = *reinterpret_cast<pulong>(hostinfo->h_addr_list[0]);
// put the ip it into an IN_ADDR
addr.S_un.S_addr = ulIP;
// changes ip into string
sprintf(szIP, "%s", inet_ntoa(addr));
TRACE("My IP address is %s\n", szIP);
}
Regards,
Simon
|
|
|
|
|
Hai,
Thanks for your message. But when i copy the given code lot of errors occured. IN_ADDR undeclared identifier etc.
I have not insatlled Platform SDK. For running the code may i need the Paltform SDK?
regards
Anish
|
|
|
|
|
Sorry, yes you will definitely need the platform SDK.
Regards,
Simon
|
|
|
|
|
How can I check the CPU usage (like in the taskmanager)?
Thanks
Yaniv
|
|
|
|
|
Check out the WMI class, Win32_Processor .
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
I want to convert a number like (i=3546246547) to a string variable( str='3546246547') and vice versa. How can we do this?
Mehdi Hosseinpour
|
|
|
|
|
try the atoi and _itoa or use CString:
CString str;
int i = 3546246547;
str.Format("%d",i);
|
|
|
|
|
CString is MFC specific.
If you're not creating an MFC application and don't want to bloat your code use the following CRT data conversion routines.
strtoul, wcstoul - Converts string to unsigned long integer.
_ultoa, _ultow - Converts unsigned long to string.
For more data conversion functions search MSDN for "Data Conversion Routines"
|
|
|
|
|
there is also another way to convert values into strings with the sprintf() fonction :
<font style="color:blue;">#include</font> <string.h>
<font style="color:blue;">int</font> sprintf(<font style="color:blue;">char</font>* buffer, <font style="color:blue;">const char</font>* format, ...);
<font style="color:green;">
you can use it like printf(), giving it a pointer to where the string will be stored
TOXCCT alias Nicolas C.
|
|
|
|
|
I have some wave files that should be play every time. I want to copy them at a folder like 'INCLUDE\' and also i want open some wave files from another place. When i open this wave file program search link 'INCLUDE\' in new folder not inside project?
How can we have inside files and olso open some other files from other folders?
Mehdi Hosseinpour
|
|
|
|
|
I don't know if I unserstand you correctly...
But if you want to open files that are not in the working directory of your application, you just have to specify complete path ("c:\\My Documents\\Test.wav"). Don't forget to put the character '\' twice because otherwise it is interpreted as a special character.
If you want to access a folder related to your working folder, you can use the "..\\Test.wav" like in dos (this opens a file that is in the root folder of your working directory).
Hope this helps
|
|
|
|
|
cedric moonen wrote:
...you can use the "..\\Test.wav" like in dos (this opens a file that is in the root folder of your working directory).
The ".." denote the parent folder of the current, or working directory. The root folder is simply expressed as "\\".
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Hum sorry, my english is not as good as I want !
Yes, of course that's what I wanted to say but I expressed it as root folder of working folder...
|
|
|
|
|
I have created a dialog with 4 sets of radio buttons groups.
for the first 2, its working fine.
but for the rest of the radio buttons group, only one is selecting. When the save and close, its saved. But while displaying, its displaying as only one radio button checked out of all.
Where the problem would be?
|
|
|
|
|
Hai
Your question is not cleared. I think the problem is where the groups u have created. Please confirm that the group check box for the First radio button of every group should be marked.
Regards
Anish
|
|
|
|
|
The radio button grouping uses the tab order for determining the group to which the radio button belongs.
In english, this means that in your dialog resource, the tab order of the radio buttons must run from RADIO_1_GROUP_1 -> RADIO_2_GROUP_1 -> RADIO_1_GROUP_2 -> RADIO_2_GROUP_2 -> etc. in a consecutive order. So, if the first radio button has tab order 3, the next must have 4, the next 5 and so forth.
Now, only the first button of each group should have the group flag set. This flag determines the starting point of the group. Whenever a control with a group flag set is found in the tab order, a new group begins. All radio buttons before this 'flagged radio button' belong to the group specified by the previous 'flagged button'. If no previous group is found before the start of the tabbing order, then those controls remain ungrouped.
Here[^] is a link to MSDN for more information.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Thanks. My Problem is solved
|
|
|
|
|
I'm trying to retrieve a few lines of text from a file and then concatonate them into a TCHAR variable.
The entire lines of text amount to around 170 characters in length and the TCHAR receiving each file line is is set to _TCHAR fileLine[4000].
The memory allocation for the overall concatonated string is:
completeString = (_TCHAR*)malloc(4000);
I'm simply using the instruction:
_tcscat(*completeString, fileLine);
to concatonate.
The problem is that the line concatonations stop after around 150 characters for no real reason that I can see (and halfway through a fileLine), even thought the _TCHAR fileLine variable continues to hold the whole of the next string in sequence correctly.
Any ideas?
Thanks for any time,
Tom.
|
|
|
|
|
First off, why are you using malloc as apposed to new? Is this C? (as apposed to C++).
Second - is the text file you are reading ASCII? Or Unicode? _TCHAR = char for ASCII builds or w_char for Unicode ones - it doesn't really help you here as the text file is always going to be one type or the other regardless of your build.
The thing to keep in mind is _tcscat will stop if it finds a \0 somewhere in the string - try executing a _tcslen on the 'fileLine' that is stoping at 150 chars or so, what does that return? If that returns the shorter length, it's possiable the string being read in has embedded \0's that _tcscat is stoping when it finds it.
|
|
|
|
|
It's C++, but I'm a novice. Bare with me.
The file is ASCII.
I've been messing around with this and the concat works fine for normal char functions and produces the expected output. I tried to convert this output to _TCHAR (this string is later going to be passed into a DB package (PL/SQL)) and again, it cut off the conversion where the original code stopped concatonating?
Any thoughts?
Cheers,
Tom.
|
|
|
|
|
No worries,
If the file is ASCII then _TCHAR is of no use to you.
TCHAR is a special define that maps to plain old char when _UNICODE is not defined, and to wide char (IE a unicode char, w_char) when _UNICODE is defined. Are you defining _UNICODE for your project? Could you put up the code you are using to read the file line please.
Try replacing _TCHAR with char and _tcscat with strcat and let me know if it still complies. If not, you have some unicode issues going on - if you want to convert the char string to unicode you need to use something like MultiByteToWideChar etc.
Also, why are you derefrencing completeString ? _tcscat takes arguments of TCHAR*, if completeString is of type TCHAR* you end up with TCHAR when you derefrence it, im supprised that even compiles..
Try something like this:
char aSmallLine[400] = {0};
char* apCompleteString = new char[4000];
memset(apCompleteString, 0, 4000);
while(<read a line from the file and put it in aSmallLine>)
{
strcat(apCompleteString, aSmallLine);
}
// do something with apCompleteString
delete [] apCompleteString;
|
|
|
|
|
does anyone know how i could display the prompt of my menu items into my MFC dialog status bar ?
the string table is already created, but i can't find the way of catching such a text when the miouse is over an item...
thx all
TOXCCT alias Nicolas C.
|
|
|
|
|
Hi all,
I'd created a DLL with Automation option checked. After building the project, from Tools->Register control i registered the dll and it showed the message, dll successfully registered. But when i check thr registry, i can't find the dll.Where am i going wrong?
rgrds
kevcs2
|
|
|
|
|
I would like to save what I draw in my CDC into the bitmap.
But I cannot find the way how to do it.
It would be enough to store it into CBitmap
(the way how to save CBitmap into .bmp file I already know
Something like how to implement function:
bool SaveDC(CDC device, LPCTSTR lpszFile)
Thank you
viliam
|
|
|
|