|
use the visual studio installer, and include msvc60 as a merge module, that should solve your problem right there.
hey
|
|
|
|
|
I'm writing a program that gets a computer name from a list of IP address. The first time thru it gets the computer name without a hitch. From then on I keep getting a error.
Here is a snippet of my code that does the gethostbyaddr.
}<br />
LPHOSTENT lphp;<br />
struct in_addr in_addrIP;<br />
<br />
<br />
<br />
if (!InitSocket()) <br />
{<br />
AfxMessageBox("Error initializing WSAStartup", MB_OK | MB_ICONSTOP);<br />
return -1;<br />
}<br />
<br />
in_addrIP.S_un.S_addr = inet_addr(szAddress);<br />
lphp = gethostbyaddr((char FAR *)&in_addrIP, sizeof(struct in_addr), PF_INET);<br />
<br />
if (lphp == NULL)<br />
{<br />
AfxMessageBox("Failed at gethostbyaddr", MB_OK | MB_ICONSTOP);<br />
return -1;<br />
}<br />
<br />
WSACleanup();<br />
<br />
return lphp->h_name;<br />
<br />
<br />
}
Am I supposed to initialize something before I give it another address to try?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Yes, you must reinitialize winsock after WSACleanup().
Kuphryn
|
|
|
|
|
I am. Each time I drop into this fuction it runs the InitSocket().
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Which does what? The counterpart to WSACleanup() is WSAStartup(). If your "convert" function is being called multiple times, I'd move the calls to WSACleanup() and WSAStartup() so they are only called once.
|
|
|
|
|
Understandable. I'll try that. Although that should not make a difference since each time I come out of this function I clean up the socket. And each time I come into it with a new ip address, it's initialized.
There may be some resouce overhead with doing it this way which is why I may take up your suggestion and move it out of this function and only do it once, but this still does not fix my problem.
Any other suggestions?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Tom Wright wrote:
Any other suggestions?
Not without knowing what InitSocket() does. If it calls WSAStartup(), which might be failing, what does WSAGetLastError() return?
In your original post, you state that "From then on I keep getting a error." but give no indication as to the error or the line causing it.
inet_addr() can return INADDR_NONE but there is no check for that.
gethostbyaddr() can return any number of errors, but none are being checked for. Call WSAGetLastError() to find out.
|
|
|
|
|
David
Thanks for the quick response.
InitSocket =
<br />
WSADATA wsaData;<br />
int retVal = NULL;<br />
<br />
retVal = WSAStartup(MAKEWORD(2,2), &wsaData);<br />
<br />
if(retVal)<br />
{<br />
return -1;<br />
}<br />
<br />
return 1;<br />
If initsocket comes back with a -1 then WSAStartup failed.
DavidCrow wrote:
In your original post, you state that "From then on I keep getting a error." but give no indication as to the error or the line causing it.
Yeah sorry for the confusion. Basically it's failing at the gethostbyaddr.
I guess I wasn't that clear in my subject line.
I haven't done a WSAGetLastError...brain freeze or something.
The way this app works is that I have a list of IP address. I get the first IP address and ping it. If it response then I drop down to this function and get the computer name. Then come back to my calling function and get the next IP address. Ping it and if there is a response then I drop down to this fuction. If there is no response then drop to some other function.
My problem is that the very first time it comes to this function is works fine and returns back the computer name. The second, third, fourth, etc times it comes to this function it errors out.
I'll run the WSAGetLastError and see what I get returned back. I just thought that I need to initialize somthing that I wasn't
Thanks for the help
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
David
I found my problem. Sometimes I feel really stupid.
First I put in my error checking function that calls WSAGetLastError. After it started going down my list of IP addresses it errored out after the first one with a strange error. After reading the error I realized....what if the ip addresses at the beginning of the list did not have a NETBIOS name?
So after looking at the ip addresses and trying different ones that I was sure was associates with a pc it worked fine. After further searching I found that the ones (ip addresses) that were erroring out were ones associated to ras servers and print servers. Not pc's but like the jet direct print server. DUH!!! I can't believe that I overlooked that.
Thanks for all the help. Sometimes it's worth posting on this forum just so that someone can give you that differnt look at the problem.
Thanks again
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Hi,
I asked this question a long while ago but all the suggestions were too complex for a beginner like me :P
anyway, basically, what is the easiest way to compare two files, given just their path names.
The best one i found on here seemed to have about 500 compilation warnings... vDiff i think it was called..
it's for a windows only program btw, if that makes a difference.
Thanks in advance, you could be lifesavers.
cheers
Col
|
|
|
|
|
The simplest is from the command line type:
fc /b file1 file2
(Of course, replace file1 and file2 with the appropriate file names.)
|
|
|
|
|
Hi Guys,
I am facing a problem while playing with different styles of the Edit Control. I want to toggle between the alignement styles ES_LEFT,ES_RIGHT and ES_CENTER at run time through selecting them through radio buttons. I have tried to do it through the following code, but it does't work in case of above stated style bit whereas the same code
works correct for ES_LOWERCASE and ES_UPPERCASE bits;
DWORD dwStyleOld;<br />
DWORD dwStyleNew;<br />
CRect rect;<br />
dwStyleOld = m_EditCtrl.GetStyle();<br />
dwStyleNew = dwStyleOld & ~ES_LEFT;<br />
dwStyleNew = dwStyleNew | ES_CENTER;<br />
m_EditCtrl.ModifyStyle(dwStyleOld, dwStyleNew);<br />
m_EditCtrl.GetWindowRect(&rect);<br />
InvalidateRect(&rect);
Regards,
Nasir Maan
|
|
|
|
|
Try something like this instead:
<br />
DWORD dwStyle = GetWindowLong( GWL_STYLE );<br />
dwStyle &= ~ES_LEFT;<br />
dwStyle |= ES_CENTER;<br />
SetWindowLong( GWL_STYLE, dwStyle );<br />
There are 10 kinds of people - those that get binary and those that don't.
|
|
|
|
|
sir,
I have tried it also...but unfortunately there is no success.
Regards,
Nasir
|
|
|
|
|
Try this instead:
m_EditCtrl.ModifyStyle((ES_LEFT | ES_CENTER | ES_RIGHT),ES_CENTER); The first argument to ModifyStyle are the styles to be removed, and the second argument are the styles to set. So ModifyStyle does the 'and-not' and 'or' operations for you.
Software Zen: delete this;
|
|
|
|
|
Netmeisters,
I am trying to do something which should be simple. Using Visual C++ I want to create a map containing an STL string as a key and my own type as a value.
#include <string>
#include <map>
#include <iostream>
using namespace std;
map<string,CReport>slips;
Then to add a pair to the map:
string str;
pair<map<string,CReport>::iterator, bool> ret =
slips.insert(map<string,CReport>::value_type(str,report));
But this produces a host of error messages that I've included below.
Can't figure these out at all. When I comment out the pair<map etc line the messages go away.
Any assistance much appreciated.
Matthew Fleming
mgf@mcw.edu
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(138) : while compiling class-template member function 'bool std::less<_Ty>::operator ()(const _Ty &,const std::string &) const'
with
[
_Ty=std::string
]
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\map(36) : see reference to class template instantiation 'std::less<_Ty>' being compiled
with
[
_Ty=std::string
]
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(19) : see reference to class template instantiation 'std::_Tmap_traits<_Kty,_Ty,_Pr,_Alloc,_Mfl>' being compiled
with
[
_Kty=std::string,
_Ty=CReport,
_Pr=std::less<std::string>,
_Alloc=std::allocator<std::pair<const std::string,CReport>>,
_Mfl=false
]
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(61) : see reference to class template instantiation 'std::_Tree_nod<_Traits>' being compiled
with
[
_Traits=std::_Tmap_traits<std::string,CReport,std::less<std::string>,std::allocator<std::pair<const std::string,CReport>>,false>
]
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(83) : see reference to class template instantiation 'std::_Tree_ptr<_Traits>' being compiled
with
[
_Traits=std::_Tmap_traits<std::string,CReport,std::less<std::string>,std::allocator<std::pair<const std::string,CReport>>,false>
]
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xtree(101) : see reference to class template instantiation 'std::_Tree_val<_Traits>' being compiled
with
[
_Traits=std::_Tmap_traits<std::string,CReport,std::less<std::string>,std::allocator<std::pair<const std::string,CReport>>,false>
]
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\map(77) : see reference to class template instantiation 'std::_Tree<_Traits>' being compiled
with
[
_Traits=std::_Tmap_traits<std::string,CReport,std::less<std::string>,std::allocator<std::pair<const std::string,CReport>>,false>
]
c:\Palm\dpCold\DpCGenCond.cpp(201) : see reference to class template instantiation 'std::map<_Kty,_Ty,_Pr,_Alloc>' being compiled
with
[
_Kty=std::string,
_Ty=CReport,
_Pr=std::less<std::string>,
_Alloc=std::allocator<std::pair<const std::string,CReport>>
]
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)' : could not deduce template argument for 'const std::_Tree<_Traits> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::list<_Ty,_Alloc> &,const std::list<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::list<_Ty,_Ax> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::list<_Ty,_Alloc> &,const std::list<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::list<_Ty,_Ax> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::list<_Ty,_Alloc> &,const std::list<_Ty,_Alloc> &)' : could not deduce template argument for 'const std::list<_Ty,_Ax> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::reverse_iterator<_RanIt> &,const std::reverse_iterator<_RanIt> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::_Ptrit<_Ty,_Diff,_Pointer2,_Reference2,_Pointer2,_Reference2> &,const std::_Ptrit<_Ty,_Diff,_Pointer,_Reference,_Pointer2,_Reference2> &)' : could not deduce template argument for 'const std::_Ptrit<_Ty,_Diff,_Pointer2,_Reference2,_Pointer2,_Reference2> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::_Ptrit<_Ty,_Diff,_Pointer2,_Reference2,_Pointer2,_Reference2> &,const std::_Ptrit<_Ty,_Diff,_Pointer,_Reference,_Pointer2,_Reference2> &)' : could not deduce template argument for 'const std::_Ptrit<_Ty,_Diff,_Pointer2,_Reference2,_Pointer2,_Reference2> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::_Ptrit<_Ty,_Diff,_Pointer2,_Reference2,_Pointer2,_Reference2> &,const std::_Ptrit<_Ty,_Diff,_Pointer,_Reference,_Pointer2,_Reference2> &)' : could not deduce template argument for 'const std::_Ptrit<_Ty,_Diff,_Pointer2,_Reference2,_Pointer2,_Reference2> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2784: 'bool std::operator <(const std::pair<_Ty1,_Ty2> &,const std::pair<_Ty1,_Ty2> &)' : could not deduce template argument for 'const std::pair<_Ty1,_Ty2> &' from 'const std::string'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\functional(139) : error C2676: binary '<' : 'const std::string' does not define this operator or a conversion to a type acceptable to the predefined operator
|
|
|
|
|
It compiles fine for me, are you sure it's not some other thing that is causing the trouble? Maybe post some of the code surrounding this snippet.
cheers,
-B
|
|
|
|
|
For extracting the essence out of these weired error-messages, you can try using STLError Decryptor[^]
For me, it works fine - and it is free
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
You must make sure you have an #include <string> in your source file. Frequently you'll get things to compile with the declarations looking fine, but when usages start if the actual include isn't there then the compiler doesn't know what to do. I think this is being caused by the underlying compiler mechanics of how it instantiates templates.
|
|
|
|
|
Hello all,
How can i send a fax(by dialing a phone number and then sending the fax) by VC++ ?
Please introduce to me some documents and source codes
Regards,
Hadi Rezaee
|
|
|
|
|
TAPI will handle the dialing of the phone number. Sending the FAX is much harder because the protocol isn't supported natively in Windows.
If you are using Win2k have a look at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fax/faxabout_3wv9.asp[^]
Michael
'War is at best barbarism...Its glory is all moonshine. It is only those who have neither fired a shot nor heard the shrieks and groans of the wounded who cry aloud for blood, more vengeance, more desolation. War is hell.' - General William Sherman, 1879
|
|
|
|
|
Hello dear Michael
Thanks for reply, the document was useful too
hmm, I'll talk with my boss about it ...
In fact the current version that i'm working on it has named Special Version and actualy it has special users, not public version, and i think we should limit the user (WinXP is good choose !!!)
The last Microsoft Fax Service is supported by WinXP and WinDotNet2003
Best Regards,
Hadi
|
|
|
|
|
Hi,
I'd like to know how to kill a known process without knowing its process id. For example, if I have a process listed in the taskmanager process list as "bad_process", can I use the string "bad_process" as input to some function in order to get a handle on that process to kill it?
Any help would be appreciated.
Many thanks in advance.
Sincerely,
Jonathan.
|
|
|
|
|
There is a Kill.exe util that comes with some resource kits that takes a process name, internally looks up the process id and then calls terminate process using that id. MSDN has the sample project that builds this tool and shows you how to look up the process id based on title. You can get the sample here[^].
|
|
|
|
|
Many thanks Erik! That is all I need for my purposes.
Cheers,
Jonathan.
|
|
|
|
|