|
I have now:
in a header file:
DWORD WINAPI WorkerThread (LPVOID WorkContext);
...
in function definition:
DWORD WINAPI CMcastMFCNoSockDlg::WorkerThread (LPVOID WorkContext)
...
in main win:
HANDLE ThreadHandle;
....
calling function:
ThreadHandle = CreateThread (NULL,0,(__stdcall) WorkerThread,NULL,0,&ThreadId);
it now complains about:
syntax error : '__stdcall'
Please, one more shot.
Thanks,
|
|
|
|
|
Like this
In the class
static DWORD WINAPI WorkerThread(
LPVOID WorkContext);
Then in the defination:
DWORD WINAPI CMcastMFCNoSockDlg::WorkerThread (LPVOID WorkContext)
Then in your calling function
ThreadHandle = CreateThread (NULL,0,WorkerThread,NULL,0,&ThreadId);
|
|
|
|
|
Strange - got your email "
From: vglmco (vladimir.gershman@lmco.com)
this is not a class:
DWORD WINAPI WorkerThread(
LPVOID WorkContext);
does it matter?
I still get an error.
Thanks,
cheers
"
But no post.
Not a class???? In your previous post you say:
in function definition:
DWORD WINAPI CMcastMFCNoSockDlg::WorkerThread (LPVOID WorkContext)
That looks to me like the WorkerThread function belongs to the CMcastMFCNoSockDlg class?
Either:
Declare WorkerThread as a global function out side any class as DWORD WINAPI WorkerThread(LPVOID lpVoid) and also define it outside the class, or declare it inside the class as a static method with the same signature.
|
|
|
|
|
I have created a CDHtmlDialog base application and I want to create IHTMLOptionElement from an external source into an IHTMLSelectElement. I have managed to do this. However, I am not sure if my code will leak:
// SelectID is already empty
CComPtr<IHTMLSelectElement> pSelect;
HRESULT hr = GetElementInterface(_T("SelectID"), &pSelect);
if (FAILED(hr)) return;
CComPtr<IHTMLWindow2> pWindow;
hr = m_spHtmlDoc->get_parentWindow(&pWindow);
if (FAILED(hr)) return;
CComPtr<IHTMLOptionElementFactory> pOptionFactory;
hr = pWindow->get_Option(&pOptionFactory);
if (FAILED(hr)) return;
while (Source.MoveNext())
{
CComPtr<IHTMLOptionElement> pOption;
hr = pOptionFactory->create(CComVariant(Source.Col(0), Source.Col(1),
CComVariant(VARIANT_FALSE), CComVariant(VARIANT_FALSE), &pOption);
if (FAILED(hr)) return;
CComPtr<IHTMLElement> pElement;
pElement = pOption; // This works but what is it doing?
// IHTMLSelectElement::add(IHTMLElement*, VARIANT);
hr = pSelect->add(pElement, CComVariant(-1)); // This works!
if (FAILED(hr)) return;
}
Is the code "pElement = pOption;" used correctly above?
Geo
|
|
|
|
|
Thats fine.
The assignment operator for CComPtr will call AddRef for you, or in this case take an assigment from the underyling IUnknown of pOption and do a QueryInterface on it for you - which in tern does the AddRef.
When using the assingment operators you should always check the assinged pointer for NULL as this is the only way CCom(QI)Ptr has to report any failure code for you - unlike when you call QI manually and you get your HRESULT back
|
|
|
|
|
I'm tring to set some shape as same color of gray color of current Dialogbox.
But I can't set exactly. RGB(200,200,200) is close but
Is there any macro for system Gray color ?
Please help me ~
Thank you
|
|
|
|
|
|
I am trying to develop application with customized ocx.
when I allocate memory more than 450 mb with globalalloc
function it fails and returns 0x000000. the problem is
after calling the CreateDispatch function. I can successfully
call this globalalloc and allocate more than 450mb before
CreateDispatch function is called.
Any help is appreciated.
Thax
shin
|
|
|
|
|
Hello,
I am trying to write a Yahoo chat client.. I have found quite a bit of resources on the net but I am having problems trying to figure some of this stuff out..
After constructing a string and sending it to the yahoo server I should receive a "challenge" string back from the server.. I have a feeling my string being sent isn't configured correctly.. My resource is from the following website;
http://www.venkydude.com/articles/yahoo.htm
...... Directly cut from the website ......
0x0000 00 20 18 8F C8 16 00 50-BA 89 95 6B 08 00 45 00 . .È..Pº‰•k..E.
0x0010 00 4A F7 6A 40 00 80 06-BA 99 C0 A8 01 C1 D8 88 .J÷j@.€.º™À¨.Á؈
0x0020 AD B7 07 0D 13 BA 7F DC-96 ED DA E7 49 68 50 18 ·...ºÜ–íÚçIhP.
0x0030 44 5C F8 02 00 00 59 4D-53 47 00 0B 00 00 00 0E D\ø...YMSG......
0x0040 00 57 00 00 00 00 6D 61-93 13 31 C0 80 73 75 6E .W....ma".1À€sun
0x0050 64 61 6D 61 6D 61 C0 80- damama
Let us look at what exactly is being sent
YMSG- is the yahoo standard header for all messenger command/messages
This is followed by 2 bytes of data - 00 0B. -this indicates the version number of the protocol
This is followed by 2 bytes of data - 00 00
Next 2 bytes specify is the length of the message information-i.e total lengthof the string -length of the header(20 bytes)
The next bytes of data is 00
This is followed by the charecter "W" this signifies that the command being sent is a challenge command
Next is a 4 byte are -00 00 00 00
The next 4 bytes is what i call the initial 4 bytes bluff identifier.
These 4 bytes identify a particular user and it changes every time you log in.
Initially you could send any four bytes including 00 00 00 00 and you would
still be able to log in .
This is followed by one byte of data signifying that the data being sent is for logging into the server.
This byte has an ASCII equivalent of "0" This is followed by 1 byte of data - 31 whose ascii equivalent is "1"
This is followed by 2 bytes of data which is the standard argument separator.- C0 80
Finally this is followed by the yahoo user id and the standard argument separator.
Here is what I have written.. I'm sure I am messing up somewhere.. Can anyone give me any pointers??
CString strMsg;
strMsg.Format("YMSG%X%X%X%X%X%X%XW%X%X%X%X%X%X%X%X01%X%Xjones_2529%X%X",
0x00, 0x0B,
0x00, 0x00,
0x00, 0x15,
0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0xC0,0x80,
0xC0, 0x80
);
...... send strMsg to the yahoo server, should receive a challenge string.
Thanks!
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
what does the library #include <iostream.h> include?
|
|
|
|
|
iostream.h?
you better include <iostream> (without the ".h")
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Yes the correct way in C++ is #include <iostream>
John
|
|
|
|
|
#includes never include any library only the definations of the function, varriables, etc...
To include the lib you need to add the lib file in the link tab in the project settings.
|
|
|
|
|
I want to use <i>unsigned char</i> variable in a function that need <i>const char*</i>, my compiler give me error which say this:
<b>Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast</b>
So I use reinterpret_cast like this but again I get compiler error:
const char* val = reinterpret_cast<unsigned char[4096]>( buf );
So what compiler option should I use or cast function or correct syntax or better solution? According to MSDN <code>reinterpret_cast</code> is not safe, any better solution for this? I use VC6 .
|
|
|
|
|
How about
const char* val = reinterpret_cast<const char*>( buf );
John
|
|
|
|
|
Ok thank, it works, but do you know safer way? About what I mention the thing MSDN say? Is that OK?
And another question. I think I should delete or release this char * from memory in the end? How is that exactly?
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
That is the standard disclaimer that casting is an unsafe operation because it bypasses the compilers type checking. In this case it is safe.
Mazdak wrote:
I think I should delete or release this char * from memory in the end? How is that exactly?
No, there is no new memory allocated by this cast so do not try free ore release any...
John
|
|
|
|
|
John M. Drescher wrote:
No, there is no new memory allocated by this cast so do not try free ore release any...
Oh, got it. Thanks for the help
Mazy
"A bank is a place that will lend you money if you can prove that you don't need it." - Bob Hope
|
|
|
|
|
Say I create a Menu with 6 choices. How do I get the computer to read the input from the user.
Preferably in C language
|
|
|
|
|
int input;
scanf("%i", &input);
Artificial intelligence is no match for natural
stupidity.
|
|
|
|
|
i have win32 project and i want to add FindWindow call:
HWND hwnd = ::FindWindow(NULL, TEXT("Calculator"));
However, it keeps on giving me link error:
UDP_Multicast_IOCP_CLIENT.obj : error LNK2001: unresolved external symbol __imp__FindWindowA@8
i use headers:
#include "windows.h"
#include "Winuser.h"
i am a novice so execuse me if i ask a stupid question.
thanks
cheers
|
|
|
|
|
link with User32.lib or put this line in your source:
#pragma comment(lib,"user32.lib")
John
|
|
|
|
|
This was it. You are the best.
thanks much,
cheers
|
|
|
|
|
You might check to see if you are linking with user32.lib in your project options.
vglmco wrote:
i ask a stupid question
A stupid question is one that is never asked.....
Artificial intelligence is no match for natural
stupidity.
|
|
|
|
|
That was exactly it. Thanks.
Although when i added this to Visual Studio 6, "project -> settings->link->WS2_32.LIB, user32.lib", it complained that it could not find WS2_32.LIB.?
Thanks,
cheers
|
|
|
|