|
thanks,
Actually my application is build for all these platform.
And i want to design all code into one application, that time i just need to build at different platform only to support it.
Thanks again
|
|
|
|
|
|
Hi all
How do I get my IP address by code? Whats the shortest way possible? I tried getenv but I found out not every computer has their IP add in their environment variables.
Thanks,
Jayjay
|
|
|
|
|
get host name first and then get the details. The following code might be helpful:
char host_name[128];
hostent* host;
gethostname(host_name,128);
host = gethostbyname(host_name);
printf("The local host: Address : %s\n", inet_ntoa(*(struct in_addr*)host->h_addr));
Regards
|
|
|
|
|
Hi kcynic,
the gethostname didnt fill up the host_name. Is there a requirement before using your code?
Thanks,
Jayjay
|
|
|
|
|
did you forget to call WSAStartup?
|
|
|
|
|
Hi kcynic,
It is working now however there is no h_addr just h_addr_list[0] in the struct of hostent, I still can't find the ipadd. Whats your advise on this?
Thanks,
Jayjay
|
|
|
|
|
Hmm, interesting.
With the following code compiled and linked with wsock32, I get an output of
Hostname: xpDesktop
The local host: Address : 210.84.23.xxx
Press any key to continue . . .
#include <windows.h>
#include <winsock2.h>
#include <stdio.h>
int main()
{
char host_name[128];
hostent* host;
WORD verRequested = MAKEWORD(1,1), err;
WSADATA wsaData;
err = WSAStartup(verRequested, &wsaData);
gethostname(host_name,128);
printf("Hostname: %s\n", host_name);
host = gethostbyname(host_name);
printf("The local host: Address : %s\n", inet_ntoa(*(struct in_addr*)host->h_addr));
WSACleanup();
system("pause");
}
|
|
|
|
|
in winsock2.h:
struct hostent {
char FAR * h_name; /* official name of host */
char FAR * FAR * h_aliases; /* alias list */
short h_addrtype; /* host address type */
short h_length; /* length of address */
char FAR * FAR * h_addr_list; /* list of addresses */
#define h_addr h_addr_list[0] /* address, for backward compat */
};
if you call WSAStartup first, you should get the result.
|
|
|
|
|
Actually yes i called WSAStartup first
The host name is jdeguzman however the h_addr_list[0] value is
*jdeguzman
which i dont get why it returns that instead my ip address.
Thanks,
Jayjay
|
|
|
|
|
yes, my result is similar to yours.
and the ip result is returned by calling inet_ntoa function.
what's you code look like?
of course you should check all the callings successful or not. msdn will give you more details i think.
|
|
|
|
|
Its all working now Thanks!
|
|
|
|
|
|
This is my function for you all:
char* GetIpAddress()
{
WSADATA wsaData;
char host_name[128];
hostent* host;
WORD verRequested = MAKEWORD(1,1), err;
err = WSAStartup(verRequested, &wsaData);
gethostname(host_name,128);
host = gethostbyname(host_name);
host->h_addr_list[0];
WSACleanup();
return inet_ntoa(*(struct in_addr*)host->h_addr);
}
|
|
|
|
|
Hi all,
How do I debug a child process inside VC 6.0 or VS in general. The scenario: The main program loads a dll which loads another exe(the process that I wanted to debug), I can debug the dll code fine but can't even set the breakpoint inside created process code. All the related source code was opened inside main program's IDE and all the .pdb files were copied to main program's "debug" dir.
Thanks,
|
|
|
|
|
Go to HKEY_LOCAL_MACHINE>Software>Microsoft>WindowsNT>CurrentVersion>ImageFileExecution Options. Here you can create a key with the name of your exe.[Assuming you are running windowsXP] eg MyProcess.exe.Create a new string value with the following properties. [Name = debugger, data = vsjitdebugger.exe]. Close the registry editor and start your application. When your child process with the name as "MyProcess.exe" gets launched you would be prompted to attach it with vsjitdebugger.
This would only be one way to attach a debugger to your process no sooner than it is launched.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Thanks. I just tried out the IFEO method, the debugger did get triggered but it only left me with a new instance of VS 2008 debugger option(I have both VC6.0 and 9.0 installed) for which I have no way to specify the symbol for the debugger. Is it possible to using the existing VC6.0 debugger(I'm using the VC6.0).
In addition, will DebugBreak for the debugee do the same thing?
Thanks,
|
|
|
|
|
LiYS wrote: ith a new instance of VS 2008 debugger option
You can keep VS 6.0 open and then it would show in the list to select from
LiYS wrote: n addition, will DebugBreak for the debugee do the same thing?
MSDN:The DebugBreak function causes a breakpoint exception to occur in the current process. This allows the calling thread to signal the debugger to handle the exception. The essence is clear now
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
If you have all the source code, you could simply add the following line very early in the exe:
__asm { int 3 }
This will fire a breakpoint for you to debug. Don't forgot to remove it!
Iain.
|
|
|
|
|
I want to store the following lines
4 lines make by 6 points
http://i218.photobucket.com/albums/cc275/hkgoldenon9/pic1.jpg
I make two class to define lines and points
class Cliness
{
public:
Cliness(void);
~Cliness(void);
int pt1;
int pt2;
};
class Cpointss
{
public:
Cpointss(void);
~Cpointss(void);
int line1;
int line2;
};
I make two array to store them
std::vector<cliness> m_arrayline;
std::vector<cpointss> m_arraypoint;</cpointss></cliness>
From the above example, i store as the following
m_arrayline[1].pt1 = 1;
m_arrayline[1].pt2 = 2;
m_arrayline[2].pt1 = 3;
m_arrayline[2].pt2 = 4;
m_arrayline[3].pt1 = 4;
m_arrayline[3].pt2 = 5;
m_arrayline[4].pt1 = 5;
m_arrayline[4].pt2 = 6;
m_arraypoint[1].line1 = 1;
m_arraypoint[1].line2 = NULL;
m_arraypoint[2].line1 = 1;
m_arraypoint[2].line2 = NULL;
m_arraypoint[3].line1 = 2;
m_arraypoint[3].line2 = NULL;
m_arraypoint[4].line1 = 2;
m_arraypoint[4].line2 = 3;
m_arraypoint[5].line1 = 3;
m_arraypoint[5].line2 = 4;
m_arraypoint[6].line1 = 4;
m_arraypoint[6].line2 = NULL;
i use this two arrays , because i want to find out which points is used to create a line (from m_arrayline)
&
find out which line is connected to this point(from m_arraypoint) directly and quickly.
By it makes me need to change both arrays if i add a new line on it.
How can i simplify it?
Thank you
|
|
|
|
|
Ever heard of the Microsoft Visual C++ sample project called Scribble? If not you might want to check it out.
led mike
|
|
|
|
|
I need to figure out the formula/pattern/algorithm needed to convert the number on the left into a checksum on the right. Here are a few examples
6789542137 ; 53426
7274707623 ; 13890
7608909976 ; 21097
7866018419 ; 46204
8185833863 ; 59982
8052724826 ; 68535
Please help
Thanks
|
|
|
|
|
Welcome to CodeProject. Take a moment to read these posting guidelines[^]
Cross posting is discouraged and we don't do homework for students.
led mike
|
|
|
|
|
Well do you have any ideas how I can do it. Any Techiques/website would be great. I dont even mind paying for it.
|
|
|
|
|
hdsouza1 wrote: I dont even mind paying for it.
This site does not implement any sort of pay for help model. There are some though. I imagine you can find them using Google.
led mike
|
|
|
|