|
gethostname()
bibamus, edamus, cras moriemur [eat, drink, for tomorrow we die]
|
|
|
|
|
gethostname() retrieves my machine/username/(watever...)
I need my IP number (255.23.01.121...) when I'm connected to the INET,
the one appears in ipconfig command under IP Address section.
I hope my Q is clearer now .
10X.
--BlackSmith--
"With the help of all mighty", 2001, Me.
|
|
|
|
|
There may well be some nice Win32 functions, but using the Unix socket functions:
struct hostent *ent = gethostbyname (gethostname ());
struct in_addr *in = (struct in_addr *)ent->h_addr_list[0];
printf ("My host IP is %s\n", inet_ntoa (*in));
Very messy I know, and with a distinct lack of error checking
|
|
|
|
|
i don't know how to get it in c++ under windows, but i know in java it is very easy, if help, i will post code for u.
cheers
includeh10
|
|
|
|
|
Hi,
I am trying to receive a HWND_BROADCAST message within an ATL application. I have tried:
1) Adding "ON_REGISTERED_MESSAGE(WM_CFM, OnMyMessage)" to the MessageMap but that doesn't appear to work in a ATL project.
2) I have tried overriding DefWindowProc() and ProcessWindowsMessage, but they are never called.
Can anyone offer me any advice?
Cheers
Richard
|
|
|
|
|
I assume that you have called RegisterWindowsMessage in both the sending and receiving applications.
Happy programming!!
|
|
|
|
|
I saw sample code using sockets and, in the client application, before calling connect there was a bind call, apparently doing nothing.
Was it really necessary?
rechi
|
|
|
|
|
It depends. The client might have wanted to bind to a specific port for some reason. If the sockaddr structure was given a number other than 0 then the client wanted to use a specific port on its end.
bibamus, edamus, cras moriemur [eat, drink, for tomorrow we die]
|
|
|
|
|
TCP:
Server - needs a bind before listen
Client - no bind needed
UDP:
Server and Client - if You use bind You will be able to use send and recv, but You might also use sendto and recvfrom. In that case bind is not needed.
Railgun is like a Gilette Mach 3 - it does the job with one, easy stroke.
|
|
|
|
|
AAAaahhh. My mistake, sorry.
As for TCP it's all true, but as for UDP:
Client - bind is not needed and You can use connect function with send/recv or sendto/recvfrom without connect
Server - bind is needed to specify the address and port
Uh, it's been a long time since i've used sockets. Sorry again, and sorry in advance if I made any more mistakes
Railgun is like a Gilette Mach 3 - it does the job with one, easy stroke.
|
|
|
|
|
Thanx both of you for your efforts!
rechi
|
|
|
|
|
Hi,
I have a need to move a file from one folder to another. It is a .bmp file. How do I do this from within my application.
Thanks
Regards
Ruca
|
|
|
|
|
Use MoveFile
BOOL MoveFile(
LPCTSTR lpExistingFileName, // file name
LPCTSTR lpNewFileName // new file name
);
|
|
|
|
|
I am new to VC++. Can you tell me how to go about learning VC++.
Best Regards
Venkatraman Kalyanam
Chennai - India
You are not an idiot till you open your lips (Anonymous)
|
|
|
|
|
Well, I'm sure you know this but I would suggest buying a beginners book and going through that. They normally explain the Development Environment as well as teach you some c++ and even object oriented programming.
I started with this book: "Microsoft Visual C++ 5: No Experience Required"
- by Steven Holzner.
This is a basic book with examples. Serves to show you how things are done in Visual C++ and what can be done. Not the best book, but simple enough.
I don't know what to suggest for .Net as I have not bought any books myself. And am still working on Visual C++ 6.0.
Of course if you haven't done any coding then you will have to buy a book on programming in general.
Best of luck
Ruca
|
|
|
|
|
The thing is i know how to write a Win32 dll or a ATL component. But i want to know more about MFC and other inner concepts of VC++
Best Regards
Venkatraman Kalyanam
Chennai - India
You are not an idiot till you open your lips (Anonymous)
|
|
|
|
|
www.codeproject.com
www.codeguru.com
www.maxcode.com
http://www.funducode.com/
helps u alot to learn vC++
windows programming by petzrold
MFC programming by Jeff prousise
MFC programming by Krughlinski
these are the books from Microsoft press
and they are good
as u are beginner
take VC++ programming by yp kanethkar(Indian author)
|
|
|
|
|
How to convert from unsigned short[30] to const char *
WCHAR to const char *
|
|
|
|
|
LPCWSTR sUnsignedShort = L"One string";
LPCSTR sAnsiChar = NULL;
USES_CONVERSION;
sAnsiChar = OLE2CA (sUnsignedShort);
|
|
|
|
|
// there are some code maybe useful for you
//WCHAR *,LPOLESTR and LPWSTR are same thing in win32(without UNICODE defined)
//TCHAR to WCHAR
TCHAR szModule[_MAX_PATH];
GetModuleFileName(NULL, szModule, _MAX_PATH);
USES_CONVERSION;
LPOLESTR pszModule = T2OLE(szModule);
//WCHAR to TCHAR
USES_CONVERSION;
LPOLESTR lpOleStr;
StringFromCLSID(clsid, &lpOleStr);
LPTSTR lpsz = OLE2T(lpOleStr);
CoTaskMemFree(lpOleStr);
|
|
|
|
|
I drived a class from CObject;all like this;
class CPerson :public CObject
{
public:
CPerson();
CPerson(CPerson &person);
CPerson & operator =(CPerson person);
CString m_strName;
};
CPerson::CPerson()
{
m_strNmae=_T("");
}
CPerson::CPerson(CPerson &person)
{
m_strName=person.m_strName;
}
CPerson &CPerson::operator =(CPerson &person)
{
m_strName=person.m_strName;
return *this;
}
but erro happed in compling ;the message is:
d:\microsoft visual studio\vc98\mfc\include\afxtempl.h(255) : error C2558: class 'CPerson' : no copy constructor available
d:\microsoft visual studio\vc98\mfc\include\afxtempl.h(1566) : while compiling class-template member function 'class CPerson __thiscall CArray<class CPerson,class CPerson &>::GetAt(int) const'
Error executing cl.exe.
who can tel me where is the erros!
I am Made!
|
|
|
|
|
A copy constructor is defined to get a const reference, so you have to modify the param list of your copy constructor and your operator =. It should look like (const CPerson& person) .
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
Not sure if this is the only error, but you've written m_strNmae instead of m_strName in your constructor
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
<b></b>I drived a class from CObject;all like this;
class CPerson :public CObject
{
public:
CPerson();
CPerson(CPerson &person);
CPerson & operator =(CPerson person);
CString m_strName;
};
CPerson::CPerson()
{
m_strNmae=_T("");
}
CPerson::CPerson(CPerson &person)
{
m_strName=person.m_strName;
}
CPerson &CPerson::operator =(CPerson &person)
{
m_strName=person.m_strName;
return *this;
}
but erro happed in compling ;the message is:
d:\microsoft visual studio\vc98\mfc\include\afxtempl.h(255) : error C2558: class 'CPerson' : no copy constructor available
d:\microsoft visual studio\vc98\mfc\include\afxtempl.h(1566) : while compiling class-template member function 'class CPerson __thiscall CArray<class CPerson,class CPerson &>::GetAt(int) const'
Error executing cl.exe.
who can tel me where is the erros!
I am Made!
|
|
|
|
|
Your operator= is defined in .h file incorrectly.
CPerson& CPerson::operator=(CPerson person) ;
It should really be:
CPerson& CPerson::operator=(const CPerson& person) ;
Also if you define an operator= you should also define a copy constructor
CPerson(const CPerson& other) ;
CPerson::CPerson(const CPerson& other)
{
// copy across member variables
}
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|