|
ok,...I forgot one thing.
The program should NOT be 'platform'/OS dependent. That means that it will be used on Linux, Windows,...maybe Mac OS....
the 'linked' article is for MFC,...
|
|
|
|
|
Hi there.
I can find the IP address of current system using below code but that's C++ code...
char* CLogger::GetIPAdd()
{
WORD wVersionRequested;
WSADATA wsaData;
char Name[255];
PHOSTENT HostInfo;
wVersionRequested = MAKEWORD( 1, 1 );
char *IPAdd;
if ( WSAStartup( wVersionRequested, &wsaData ) == 0 )
{
if( gethostname ( Name, sizeof(Name)) == 0)
{
if((HostInfo = gethostbyname(Name)) != NULL)
{
int nCount = 0;
while(HostInfo->h_addr_list[nCount])
{
IPAdd = inet_ntoa(*(struct in_addr *)HostInfo->h_addr_list[nCount]);
++nCount;
}
}
}
}
return IPAdd;
}
I want to get an IP Address using MFC. Can any one please help me out to get the same using MFC?
Thanks
PanB
|
|
|
|
|
MFC is just a wrapper over C++ classes functions, but what is the problem with the code above.
Even if you do find a class in MFC to get the IP address it must be using a similar sort of mechanism to get the IP Address of the local machine
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Why MFC? I am getting lots of Windows.h already included related error messages.
But if we can get IP Address in MFC then that will server my requirement.
Thanks
|
|
|
|
|
PankajB wrote: But if we can get IP Address in MFC then that will server my requirement.
do you apply ointment on your feet if you have an headache
PankajB wrote: I am getting lots of Windows.h already included related error messages.
figure out why these errors are popping and resolve them. May be you are missing a library to link to or you didn't include a header file.
BTW what are the errors?
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
PankajB wrote: I can find the IP address of current system using below code but that's C++ code...
PankajB wrote: I want to get an IP Address using MFC
MFC doesn't have functionality covering IP address resolution - if it works, your C++ code is as good as anything.
Don't get too hung up about things being in MFC or not in MFC - MFC is, for the most part, a thin veneer over Win32 functions and, overall, has a very old fashioned design , a lot of which was constrained by the deficiencies of C++ compilers in use when MFC was developed.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
PankajB wrote: ...but that's C++ code...
Nothing in your code is C++.
PankajB wrote: return IPAdd;
You are potentially returning an uninitialized pointer.
PankajB wrote: I want to get an IP Address using MFC.
Then use the same code.
PankajB wrote: Can any one please help me out to get the same using MFC?
MFC offers no such class.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thanks for the code! I just had to add the library Ws2_32.lib and the header Windows.h, works perfectly! Thanks!
|
|
|
|
|
Yeah it works perfect. Thanks a lot for the code
|
|
|
|
|
Hello,
I get compiler error error C2327: 'CMyGridEdit::OnChar' .symbol' : is not a type name, static, or enumerator..
What's wrong at this declaration ?
I have following declaration in VC++ 6.0
<<<mygrid.cpp>>
BEGIN_MESSAGE_MAP(CMyGrid::CMyGridEdit, CEdit)
ON_WM_CHAR()
END_MESSAGE_MAP()
void CMyGrid::CMyGridEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
}
<<mygrid.h>>
{
class CMyGrid : public CMSHFlexGrid
..
class CMyGridEdit : public CEdit
{
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
DECLARE_MESSAGE_MAP()
};
};
Thanks for helps. jr
|
|
|
|
|
That pattern works fine in VS2008, so the only thing I can presume is that one of the VC6 compiler's many many deficiencies is biting you.
I'd suggest you pre-process the C++ file (with CL /P) and see if anything looks untoward in the BEGIN_MESSAGE_MAP code after pre-processing (don't look for BEGIN_MESSAGE_MAP in the .i file you get out of the pre-processor - it won't be there - look for CMyGrid::CMyGridEdit::GetMessageMap instead.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
The following is the code fragment which I used in my application,
CStringb csFilePath = _T("C:\\MyFolder\\");
if(csFilePath != "\\")
{
DWORD dwError = GetLastError();
}
And i am getting an error code of 122(The data area passed to a system call is too small) in VS2008.
But in VC6.0, there is no such problem, the error code i am getting is 0.The application is with UNICODE supported.
Please help me to find out the cause of this problem.
Thanks & Regards
VIJITH VIJAYAN
|
|
|
|
|
VIJITH VIJAYAN wrote: if(csFilePath != "\\")
this should probably be
if(csFilePath != _T("\\"))
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks for the quick response .But at the compilation time this code didnt shown any errors or warnings . Do have any idea ,why it had happened like this ?
Thanks & Regards
VIJITH VIJAYAN
|
|
|
|
|
Because the CStringT == operator is overloaded to handle PCYSTR .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
VIJITH VIJAYAN wrote: And i am getting an error code of 122(The data area passed to a system call is too small) in VS2008.
Possibly because that's the last value that was set (with SetLastError() ). In other words:
SomeWindowsFunctionThatFailsWithCode122();
CString csFilePath = _T("C:\\MyFolder\\");
if (csFilePath != _T("\\"))
{
DWORD dwError = GetLastError();
} If nothing calls SetLastError(0) , then its internal value will stay 122 .
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi,
Have a quick question on Boost weak pointers. Hope this is the place to ask. I found the article
Smart Pointers to boost your
code[^]
and on the paragraph "cyclic references" in the code there is the line
<br />
child->myDad = dad;<br />
where does the dad come from? Can't seem to see it defined anywhere in the code.
Thanks for any information.
|
|
|
|
|
I think it's just a typo. Should be:
child->myDad = parent;
EDIT: You can download the sources just to be certain
|
|
|
|
|
Ha ha, yes I did think it should be parent.
Thanks!
|
|
|
|
|
Actually, if it was a typo then why does the diagram underneath refer to "dad" and the dad.reset() ? Surely that can't be a typo as well?
|
|
|
|
|
As I said before - you really should download the sources first. The code will probably clear things up
|
|
|
|
|
Why not post this message on that article rather than here?
Looking at the article, I think that's a typo - dad should be parent
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hmmm, if it was a typo to put "dad" instead of "parent", then is the diagram showing dad pointing to the CDad struct a mistake as well?
|
|
|
|
|
He probably used dad and son or boy throughout, then tried to remove the gender specificness as it could be seen as discriminatory?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hmmm, thats confusing! I'll try and email the author (if thats possible) as it is a good article and I want to get my head round it.
Thanks !
|
|
|
|