|
Hi,
I am converting one application from IPv4 to IPv6. The application is usign
MFC socket class CSocket and CAsyncSocket.
::: My Query :::
1. When I compile my application for IPv6 by defining IPV6STRICT. I am
getting errors in Afxsock.h. I believe CSocket and CAsyncSocket (for MFC 4.2)
doesn't support IPv6. Please reply if this is true.
2. How can I make sure that CSocket and CAsyncSocket supports IPv6. ?
or
3. How can I include IPv6 support for CSocket and CAsyncSocket classes. ?
::: Some Backgroud :::
1. I am using VS 6.0 with service pack 6.
2. I am using XPSP-2 SDK.
Please reply if any one has faced same problem.
Thanks for your reply.
Regards
Alpha
|
|
|
|
|
Code your own socket class.
Don't try it, just do it!
|
|
|
|
|
I strongly believe in same. Maybe i have to code my own CSocket to support IPv6 .
Thanx
Alpha
|
|
|
|
|
How do I have to connect to COM object from a simple console application. The problem I have is like that:
Client.obj : error LNK2001: unresolved external symbol _CLSID_IOConverter
Client.obj : error LNK2001: unresolved external symbol _IID_IIOConverter
Debug/Client.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
Client.exe - 3 error(s), 0 warning(s)
My code:
DEFINE_GUID(CLSID_IOConverter,...)
DEFINE_GUID(CLSID_IOConverter,...)
int main(int argc, char* argv[])
{
CComPtr<iioconverter> converter = NULL;
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
CoCreateInstance(CLSID_IOConverter,NULL, CLSCTX_INPROC_SERVER,IID_IIOConverter,(void**)&converter);
CoUninitialize();
return 0;
}
What do I have to change?
|
|
|
|
|
There's only one error in the actual code. The CComPtr is a template class, and should be declared accordingly. Either you have forgotten the < and > signs or the forum is not displaying them. Anyway they should be there.
The linker errors are generated because the GUIDs you define do not explicitly state the precise GUID numbers you wish to use. I couldn't find the IIOConverter interface definition from anywhere, so more than likely you have forgotten to link with the static library that defines these interfaces, or have forgotten to include a necessary header file. Check your settings.
There doesn't seem to be other errors. If you need more help, you need to paste the entire DEFINE_GUID macros, and not just "..." as they might cause the errors as well. Also, you have not defined the IID_IIOConverter properly, thus the error. You can use __uuidof( IIOConverter ) if you don't know the interface's GUID, but know the interface name.
Also remember that in order to use the CComPtr class, include atlcomcli.h. To use CoInitializeEx, include objbase.h and link with ole32.lib. Remember that these are Platform SDK features, so you need to define the correct versioning macros as well. For more information, see MSDN with "Platform SDK, Using the Platform SDK" index word.
Hope this helps
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Hi Dear,
I've added MS Chart Control ActiveX by Project=>Add to Project=>Companent & selected register control. That added lot of classes in my project.
Now I want to remove that ActiveX & their classes. How to do this?
Thanks
---Sumit Kapoor--- sumit_kapoor1980@hotmail.com
|
|
|
|
|
Remove the Classes. The Classes are not the control itselfe. They just interface it.
Hardy
|
|
|
|
|
Hi ,
I want to fancy window style with 3D Title bar and.
Guide me.Thank You.
|
|
|
|
|
|
Hi everyone,
Can anyone give me the sample source code how to perform serial communication in VC++?
Please guide me.
With thanks
War War....
phoophoo2004@indiatimes.com
|
|
|
|
|
|
|
Hi,
I'm trying to convert a tm structure (which has already been adjusted to GMT) into a time_t.
The mktime function adjusts for timezone but this is not what I want.
libc includes _mkgmtime (doesn't seem to be documented) but msvcrt does not.
Is there any easy way I can do this without copying the _make_time_t function from mktime.c (the common code for mktime and _mkgmtime) with all it's dependent bits.
Thanks.
|
|
|
|
|
I want to emmbed Flash (*.swf) into Visual C++ project but i don't know. Can you help me, please????????
Thank you very much!!!!
my email: quocbaonguyen@gmail.com
|
|
|
|
|
Hello,
If you are using VC6,
at the menu bar:
[Project]
[Add To Project]
[Components And Controls]
An explorer-like window(Components and Controls Gallery) will appear.
At the folder
"Registered ActiveX Controls"
select the
"Shockwave Flash Object" file and then press [Insert]
When you go back to Resource View, the activeX control for Macromedia Flash is already added to the controls tool bar.
goodluck.
|
|
|
|
|
I use code which downloaded at "http://codeguru.com/Cpp/I-N/network/networkinformation/article.php/c2441/" for my project but i can't enumerate my network.
Because my entire network (in Explorer) can't view my workgroups. I can find any computer and access any computer by "\\computer's name" in my network.
I want to enumerate my network. Can you help me? Help me, please!!!!!
Thank you very much!!!!!
my email: quocbaonguyen@gmail.com
|
|
|
|
|
Hey Guys,
I am new to the whole world of C++ and have been studying a few samples / examples off the web of C++ coding etc. I made a short code / program called "The Namorizer" which is a console program that asks for your first name, then your last and finally adds them together and displays the result i.e your full name.
What I am trying to accomplish here is to do the same thing but with a windows form. I have designed the form in VS2k3 and now would like to add the code to the various textboxes etc for the events. I am kind of lost at this point of what to do and would like someone with patience and skills in communication just to spend a few minutes explaining where I would put this and also perhaps providing me with links to good sites and tutorials to learn from.
Thank you in advance for any help you can give.
neo.
|
|
|
|
|
Basically, you need to decide how it will all work. The most simple way is to set up two text boxes, call them tbFirst and tbLast ( for example ), then add a button. Double clicking on the button in the designer will create a handler in your code for the button being clicked, although giving it a meaningful name first will mean the function will have a useful name. First create a label, and call it lblName ( for the sake of the example ). Now, from memory, what you need to do in your handler is something like
lblName.SetWindowText(tbFirst.GetWindowText()+ " " + tbLast.GetWindowText());
I'm a long way from C++ land though, let alone MFC, so I could have some of the details wrong.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Good answer to most is read:
SAMS - Teach Yourself Visual C++ In 21 Days.pdf
|
|
|
|
|
I have a Byte buffer that I'm receving data into from an CAsyncSocket call (Receive)
BOOL bRetCode;<br />
DWORD dwBytesToRead;<br />
<br />
bRetCode = m_sConnectSocket.IOCtl(FIONREAD, &dwBytesToRead);<br />
<br />
BYTE* RecvBuffer = new BYTE[(int)dwBytesToRead];<br />
<br />
m_sConnectSocket.Receive(RecvBuffer, sizeof(RecvBuffer));<br />
<br />
onParseData(RecvBuffer, sizeof(RecvBuffer));<br />
In my onParseData function I'm trying to parse out the data. I know that certain parts of the data stream are a fixed length. So I created a structure.
struct ParseData{<br />
BYTE STAP[4]; <br />
BYTE BlockLen;<br />
BYTE HDRLen;<br />
BYTE FunctionCode;<br />
BYTE ValField;<br />
BYTE DataLen;<br />
BYTE MsgStatus;<br />
BYTE Dest;<br />
char* DataPacket;<br />
BYTE STOP[4];<br />
};<br />
ParseData myStuff;<br />
memcpy(&myStuff, dataBuffer, sizeof(myStuff));<br />
My problem is that I feel that this is not going to work and that I get an exception error because of the char* DataPacket; .
And I'd love to make my sturcture like this:
struct ParseData{<br />
BYTE STAP[4]; <br />
int BlockLen;<br />
int HDRLen;<br />
int FunctionCode;<br />
int ValField;<br />
int DataLen;<br />
int MsgStatus;<br />
int Dest;<br />
char* DataPacket;<br />
BYTE STOP[4];<br />
};<br />
I just want some direction in to where I need to go to find out:
1. How do I move this BYTE array into this structure?
2. Is there a simple way to just pull out certain parts of the data stream and plop it into the structure? example...move the first 4 bytes to the STAP the second 4 to the BlockLen...etc.
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
The problem is that a char * is the address where an array of char's can be found. In unpacking your data, you need to work out how long the string is, call new on the char * in the struct, and then assign the value. If I were you, I'd put a std::string in the struct instead, that way you don't need to clean up memory.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Christian
Thanks replying so quickly. So here is the embarassing part. My main programming language is COBOL. So this structure thing is new to me. When you say to put a std::string in the struct.....what do you mean by that?
I do understand what you are saying that the char* needs to be initialized with the length that it needs to be....and the DataLen is the size of this array....but, even if I know this amount......will me doing a memcopy easily convert the data stream to the appropriate typedef? From a BYTE to an int or a char?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Tom Wright wrote:
So this structure thing is new to me.
A structure is just a class, under the hood the only difference is that members of a struct are public by default, members of a class, private by default.
Tom Wright wrote:
When you say to put a std::string in the struct.....what do you mean by that?
The problem with allocating a pointer is that you need to clean the memory afterwards. A std::string is probably overkill, a struct (being a class) can have a destructor, which can clean the memory for you. Something like this:
struct MyStruct
{
char * theString;
MyStruct()
{
theString = NULL;
}
~MyStruct()
{
if (theString)
delete [] theString;
}
}
I'm a long way from the last time I used C++, so there may be some syntax problems there.
A std::string is a class offered by the standard C++ library, which allows you to manipulate strings. Overkill in this case, especially if you're building a lot of them. To use it, you would put #include<string> at the top of your .cpp file, and then using std::string; somewhere underneath.
Tom Wright wrote:
will me doing a memcopy easily convert the data stream to the appropriate typedef? From a BYTE to an int or a char?
A byte is a char. So yes, so long as your string is NULL terminated ( ends with a 0 ), you can just call new on the char * to allocate memory, then do a memcpy across to it. If it's not null terminated, just add one to the size of the array you create, call memset on it to null it all, then copy the string in.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
What I did when I faced a similar problem is this:
#pragma pack(1) // This is important, otherwise your compiler might allign things wrong
struct ParseDataStruct{
BYTE STAP[4];
int BlockLen;
int HDRLen;
int FunctionCode;
int ValField;
int DataLen;
int MsgStatus;
int Dest;
char DataPacket[MaxSize+4]; // inlucdes the 4 STOP bytes
};
#pragma pack()
class ParseData {
protected:
ParseDataStruct Data;
public:
ParseData(BYTE * DataIn) { // constructor, pass a pointer to the data
ParseDataStruct *in = (ParseDataStruct *)DataIn; // my compiler is old and doesn't support the new C++ casts well, you should use them instead
memcpy(DataIn,&Data,in->BlockLen); // check the length of this copy
}
enum msgStats { ...}
enum FunctCode { ... }
msgStatus getMsgStatus();
FunctCode getFunctionCode();
char * getDataPacket();
...
}
That is create a class to wrap the whole thing. This class knows who things are represented. It can even pull the STOP bytes out if you need them, even though the data is variable length.
I'm sure there is a different way, and it might even be better. Thats just what I've done.
|
|
|
|
|
I'm trying to let the user change a dialog's font at runtime. It keeps crashing on me in "wingdi.cpp". this is what I have so far:
memset(&m_Font, 0, sizeof(LOGFONT));
CFont* pFont = this->GetFont();
pFont->GetLogFont(&m_Font);
CFontDialog dlg(&m_Font);
dlg.m_cf.Flags |= CF_TTONLY;
if(dlg.DoModal() == IDOK)
{
dlg.GetCurrentFont(&m_Font);
pFont->CreateFont(m_Font.lfHeight,m_Font.lfWidth,m_Font.lfEscapement,m_Font.lfOrientation,m_Font.lfWeight,m_Font.lfItalic,m_Font.lfUnderline,m_Font.lfStrikeOut,m_Font.lfCharSet,m_Font.lfOutPrecision,m_Font.lfClipPrecision,m_Font.lfQuality,m_Font.lfPitchAndFamily,m_Font.lfFaceName);
this->SetFont(pFont);
}
Note: at first I had pFont->CreateFontIndirect(&m_Font) but it crashed in the same place.
[insert witty comment here]
bdiamond
|
|
|
|
|