|
I have a console application but I don't want that black window appear.I don't need to show anything to user.How can I prevent appearing it?
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
|
Hi there, I am tryig to code a scan on IP adresses.
The scenario: there is application online, with a listener socket on a specific port. Another application is saerching for that application, only knowing the port but not the IP adresss.
So the searching appliaction has to loop thru a IP adress range to find the matching application.
The problem ist now, that such a "blind" connect on a IP-adress take a long time until a WSAETIMEDOUT error occurs and the application can go on.
Is there someone who got a good and fast solution?
(unfortunatly I can not start a directory server, because of some other reasons)
Thanks for help,
Best regards Andreas Niedermeier
|
|
|
|
|
Have you tried any of the WSAAsyncGetxxx() functions? That may not even be what you are looking for but the idea is to keep your program from blocking while it's checking. Another solution is a worker thread.
|
|
|
|
|
I don't know if you are developing or have the source code to the "application online" but if you are, why don't you just listen to a specific port -- not TCP/IP listen but UDP listen.
Just do a blocking or non-blocking recv or recvfrom in a thread for the port you want to receive communication from. Then the "searching application" can send a UDP broadcast to all computers on that subnet on that port. Since, his IP address will be the source in that packet, your listening thread in your non-searching application can take note of it and start a TCP/IP connection if required. Or, just send a reply to the "searching application" that you are there.
|
|
|
|
|
Hi everyone!
I want to use a class/struct to represent a TCP header
and another class/struct to represent a IP header. I also want
to write a checksum function for IP header and TCP header.
Someone suggesdted me to reference Libnet.
But it is too big!
My aim is simple, just represent TCP and IP header. And also
do a checksum for IP header and TCP header.
Are there some simple samples that I can refer?
Thanks in advance,
George
|
|
|
|
|
Hello,
I am developing a Dialog based application using MFC.
I have created a Modal Parent Dialog by using DoModal() method.
And also creating Modeless Child Dialogs by using Create() method.
Now I need to associate a unique id with every Child Dialog, so I could refer to them whenever I need them, by using their unique id's. Let say I want to focus one of the child dialog, or blink the caption bar.
Please anyonebody could help me in this regard
Regards
The Phantom. ™
|
|
|
|
|
Why don't you just use the pointers to the dialogs as a unique ID? If you really need some other way, you can try using SetDlgCtrlID() on the dialog, but the docs say it only works with child windows. You could try and see, but I would just use the pointers to the dialogs.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Hi, I'm having a crack at playing with the IXMLHTTPRequest interface, and I've got it mostly working, but the return type for one of the functions I need to use is BSTR, which, as I understand, is some sort of unicode string. How do I get it into a CString-friendly format?
NATHAN RIDLEY
Web Application Developer
generalgherkin@yahoo.com
|
|
|
|
|
it is assignable just write bstr = string.allocsysstring()
and yes..bstr is not a unicode string datatype..it is a binary datatype..binary string..
|
|
|
|
|
no, I mean I have the BSTR already but I want to create a CString out of it...
NATHAN RIDLEY
Web Application Developer
generalgherkin@yahoo.com
|
|
|
|
|
It's as simple as:
BSTR pbsz = L"Hello World";
CString str;
str = pbsz;
AfxMessageBox(str);
|
|
|
|
|
A BSTR is a null-terminated unicode string that is preceded by the it's length (similar to a Pascal-style string). However, the pointer actually points to the character data, so you have to decrement the pointer to read its length. However, you can just use wcslen() to get it's length exactly like a normal unicode string if you want.
To convert to a CString compatible string (LPCTSTR), use the W2T() ATL macro as such:
BSTR bstr;
LPCTSTR lpsz = W2T(bstr);
CString str = W2T(bstr);
If you don't want to use ATL, have a look at the WideCharToMultiByte() WIN32 function, but I prefer the ATL way - it's much simpler!
Hope this helps,
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Argh! I completely forgot that a BSTR may contain NULLs, so wcslen() may give you a length that is less than the length stored in the string itself. If this is the case, then you won't be able to operate on it like it was a CString. Just put in a test to see if the lengths are equal. If they are, then you can convert it to a CString like I said above. If not, then you'll have to find some other way... Hopefully I've given you enough information about BSTRs to find another way
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Hey thanks! Much appreciated Umm, forgive my ignorance, though, I get an undeclared identifier error on the W2T macro. I assume I'm missing a header file or something?
NATHAN RIDLEY
Web Application Developer
generalgherkin@yahoo.com
|
|
|
|
|
Nathan Ridley wrote:
I assume I'm missing a header file or something?
yep, atlconv.h
Make sure you read my reply to my reply (I hope that makes sense ) for some stuff that I forgot about in my first reply.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
[Short Homer Scream]AARGH![/Short Homer Scream]
I get these errors...
D:\cdev\XMLTest\XMLTestDlg.cpp(195) : error C2065: '_lpw' : undeclared identifier
D:\cdev\XMLTest\XMLTestDlg.cpp(195) : error C2440: '=' : cannot convert from 'unsigned short *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
D:\cdev\XMLTest\XMLTestDlg.cpp(195) : error C2065: '_convert' : undeclared identifier
My code looks like this:
void CXMLTestDlg::OnButton1()
{
IXMLHTTPRequest* pIXMLHttpRequest = NULL;
HRESULT hr = CoInitialize(NULL);
hr = CoCreateInstance( CLSID_XMLHTTP,
NULL,
CLSCTX_INPROC_SERVER,
IID_IXMLHTTPRequest,
(void**)&pIXMLHttpRequest);
BSTR bstrString = NULL;
try
{
hr = pIXMLHttpRequest->open(_bstr_t(_T("GET")),
_bstr_t(_T("http://top01wdt1:8090/test.htm")),
_variant_t(VARIANT_FALSE),
_variant_t(""),
_variant_t(""));
if(SUCCEEDED(hr)) {
BSTR* pbsz = NULL;
hr = pIXMLHttpRequest->get_responseText(pbsz);
LPCTSTR lpsz = W2T(*pbsz);
CString x(lpsz);
m_szOutput = test;
UpdateData(FALSE);
}
}
catch(...)
{
MessageBox("Failure!");
}
}
NATHAN RIDLEY
Web Application Developer
generalgherkin@yahoo.com
|
|
|
|
|
Oops. Forgot one thing.
put USES_CONVERSION; at the top of your function. This macro declares the variables that the W2T macro (and all the other ATL conversion macros) use internally.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
cool, thanks for the help!
NATHAN RIDLEY
Web Application Developer
generalgherkin@yahoo.com
|
|
|
|
|
In the code I've posted (in the message that this message is a reply to) there is a bug in the bold section which causes an exception to occur. It says I'm trying to write to memory address 0x00000000, and only occurs once I try to read the value of pbsz. Can you see any obvious points where this could be caused?
NATHAN RIDLEY
Web Application Developer
generalgherkin@yahoo.com
|
|
|
|
|
Use WideCharToMultiByte() API
CodeTheDreams();
|
|
|
|
|
Short answer: You can assign a BSTR to a CString , since CString has a constructor that takes a Unicode string pointer.
Long answer: See my guide to string classes[^] for all the details
--Mike--
Yeah, payin' the bills with my mad programming skillz.
Defraggin' my hard drive for thrills.
Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
hi there..
i wanted to know if some one had a precise idea about what the macros DECLARE_OLECTLTYPE and DECLARE_OLECREATE_EX do in an activeX controls..
thanks
safee
|
|
|
|
|
hello.......how to get Child frame's handles from Main frame in MDI application?
Thanxs.....
C.R.Naik
|
|
|
|
|
You can use code similar to this. Basically, you go through each of the application document templates, to get each of the open documents. For each document (which could have multiple views), you go through each of the views, and then get the parent frame.
POSITION posTemplate = theApp.GetFirstDocTemplatePosition();
while (posTemplate)
{
CDocTemplate * pTemplate = theApp.GetNextDocTemplate(posTemplate);
POSITION posDocument = pTemplate->GetFirstDocPosition();
while (posDocument)
{
CDocument * pDocument = pTemplate->GetNextDoc(posDocument);
POSITION posView = pDocument->GetFirstViewPosition();
if (posView)
{
CView * pView = (CSpecExView *)pSpecExDoc->GetNextView(posView);
CFrameWnd * pChildFrame = pView->GetParentFrame();
}
}
}
Hope this helps!
|
|
|
|