Winsock ... problem

Hi,
I use MS. winsock activex control , I have a problem in geting data form the
socket through winsock, I have writtem the following code :
////////////////////////////////////////////////////////////////////////////
/////////////////////////
 VARIANT d;
  COleVariant type,MaxLength;
  MaxLength.vt=VT_I4;
  MaxLength.lVal=5;
  type.vt=VT_BSTR;
  d.vt=VT_BSTR;
  WSock.GetData(&d,type,MaxLength);
  CString a= _com_util::ConvertBSTRToString(*d.pbstrVal);//to change BSTR to
CString
  MessageBox(a);
////////////////////////////////////////////////////////////////////////////
/////////////////////////
this code release Illegal Operation ; this is occured when calling
GetData(), if we change the type of type and MaxLength it released
"unrecognized type".
I tried to solve this problem but I have failed.
Please help me in writing correct code without any problems.
Monther



0
Monther80 (10)
7/26/2003 7:19:12 AM
vc.mfc 33608 articles. 0 followers. Follow

4 Replies
779 Views

Similar Articles

[PageSpeed] 43

Perhaps you should call ::VariantInit First .
I am not sure this is the point .

"monther" <Monther80@hotmail.com> wrote in message
news:erNjHa0UDHA.624@TK2MSFTNGP10.phx.gbl...
> Hi,
> I use MS. winsock activex control , I have a problem in geting data form
the
> socket through winsock, I have writtem the following code :
>
////////////////////////////////////////////////////////////////////////////
> /////////////////////////
>  VARIANT d;
>   COleVariant type,MaxLength;
>   MaxLength.vt=VT_I4;
>   MaxLength.lVal=5;
>   type.vt=VT_BSTR;
>   d.vt=VT_BSTR;
>   WSock.GetData(&d,type,MaxLength);
>   CString a= _com_util::ConvertBSTRToString(*d.pbstrVal);//to change BSTR
to
> CString
>   MessageBox(a);
>
////////////////////////////////////////////////////////////////////////////
> /////////////////////////
> this code release Illegal Operation ; this is occured when calling
> GetData(), if we change the type of type and MaxLength it released
> "unrecognized type".
> I tried to solve this problem but I have failed.
> Please help me in writing correct code without any problems.
> Monther
>
>
>


0
Jackie
7/26/2003 8:48:10 AM
I mean ::VariantInit(&d) before using d
If it does not work , show me some more code if possible .

"monther" <Monther80@hotmail.com> wrote in message
news:ucTvDh1UDHA.2452@TK2MSFTNGP09.phx.gbl...
> Hi Jackie;
> Thanks for writing...
> I have tried the function but the same error has appeared.
> Please send me a code
> Monther
>
>
> "Jackie" <jackie2k@163.com> wrote in message
> news:#3#GQJ1UDHA.2272@TK2MSFTNGP11.phx.gbl...
> > Perhaps you should call ::VariantInit First .
> > I am not sure this is the point .
> >
> > "monther" <Monther80@hotmail.com> wrote in message
> > news:erNjHa0UDHA.624@TK2MSFTNGP10.phx.gbl...
> > > Hi,
> > > I use MS. winsock activex control , I have a problem in geting data
form
> > the
> > > socket through winsock, I have writtem the following code :
> > >
> >
>
////////////////////////////////////////////////////////////////////////////
> > > /////////////////////////
> > >  VARIANT d;
> > >   COleVariant type,MaxLength;
> > >   MaxLength.vt=VT_I4;
> > >   MaxLength.lVal=5;
> > >   type.vt=VT_BSTR;
> > >   d.vt=VT_BSTR;
> > >   WSock.GetData(&d,type,MaxLength);
> > >   CString a= _com_util::ConvertBSTRToString(*d.pbstrVal);//to change
> BSTR
> > to
> > > CString
> > >   MessageBox(a);
> > >
> >
>
////////////////////////////////////////////////////////////////////////////
> > > /////////////////////////
> > > this code release Illegal Operation ; this is occured when calling
> > > GetData(), if we change the type of type and MaxLength it released
> > > "unrecognized type".
> > > I tried to solve this problem but I have failed.
> > > Please help me in writing correct code without any problems.
> > > Monther
> > >
> > >
> > >
> >
> >
>
>


0
Jackie
7/26/2003 11:15:41 AM
"monther" <Monther80@hotmail.com> wrote in message
news:erNjHa0UDHA.624@TK2MSFTNGP10.phx.gbl...
Hi,
I use MS. winsock activex control , I have a problem in geting data form the
socket through winsock, I have writtem the following code :
////////////////////////////////////////////////////////////////////////////
/////////////////////////
 VARIANT d;
  COleVariant type,MaxLength;
  MaxLength.vt=VT_I4;
  MaxLength.lVal=5;
  type.vt=VT_BSTR;
  d.vt=VT_BSTR;
  WSock.GetData(&d,type,MaxLength);
  CString a= _com_util::ConvertBSTRToString(*d.pbstrVal);//to change BSTR to
CString
  MessageBox(a);
////////////////////////////////////////////////////////////////////////////
/////////////////////////
this code release Illegal Operation ; this is occured when calling
GetData(), if we change the type of type and MaxLength it released
"unrecognized type".
I tried to solve this problem but I have failed.
Please help me in writing correct code without any problems.
Monther




0
nospam1 (27)
7/26/2003 5:11:09 PM
Check your return code from WSock I think your problem is there.


"monther" <Monther80@hotmail.com> wrote in message
news:O8MBP42UDHA.2004@TK2MSFTNGP10.phx.gbl...
Thanks for writing again
Her is my code ; I have tried 2 codes as the following:(For every code I
wrote what happens)

1 COleVariant d,type,MaxLength;
2 VariantInit(&d);
3 VariantInit(&type);
4 VariantInit(&MaxLength);
5 WSock.GetData(&d,type,MaxLength);
6 CString a= _com_util::ConvertBSTRToString(*d.pbstrVal);
7 MessageBox(a);

///Illegal Operation AT LINE 6
/********************************************************/
1 COleVariant d,type,MaxLength;
2 VariantInit(&d);
3 VariantInit(&type);
4 VariantInit(&MaxLength);
5 MaxLength.vt=VT_I4;
6 MaxLength.lVal=5;
7 type.vt=VT_BSTR;
8 d.vt=VT_BSTR;
9 WSock.GetData(&d,type,MaxLength);
10 CString a= _com_util::ConvertBSTRToString(*d.pbstrVal);
11 MessageBox(a);

Unsuported VARIANT TYPES AT lINE 9
/********************************************************/
THIS CODE FOR DEALING WITH WINSOCK ACTIVEX
If you have a code to deal with it , in other words reads the incomming data
form the socket
thanks you again for your help...
Monther














0
nospam1 (27)
7/26/2003 5:13:12 PM
Reply:

Similar Artilces:

Problem with Winsock.
Hi all, I have a problem with a simple VC++ client socket programming. I hope that someone can help me to solve it. My code: int initial() { bool success = true; hp = gethostbyname("localhost"); memset(&sa, 0, sizeof(struct sockaddr_in)); memcpy((char *) &sa, hp->h_addr_list, hp->h_length); sa.sin_family = hp->h_addrtype; sa.sin_port = htons(3500); s = socket(AF_INET, SOCK_STREAM, 0); if (s == INVALID_SOCKET) success = false; else { if (connect(s, (struct sockaddr *) &sa, sizeof(struct sockaddr_in)) == SOCKET_ERROR)...

Problem linking subform
I have an Access 2003 database that I am attempting to convert to an Access project. I have copied my forms from the Access database to the Access project. One of my forms has several subforms on it. I have not been able to get any of these subforms to work. I receive a "Syntax error or access violation" error message for each subform on the form. If I remove the Link Master Field and Link Child Field properties for a subform, that subform will load, but, as expected does not refresh as I navigate through the records on my main form. I have checked and double checked tha...

WLM Windows 7
I have just started using WLM and Calender in Windows 7. However, it keep getting the following message " "Something unexpected has happened and Windows Live mMail has had to close down". My imported contacts also disappeared (now reimported) and it seems to happen when I have Calender open (but I'm not sure that it always happens when it is open). I have looked for fixes and tried the following: On AVG I removed the email scanning option. (Failed to work) I have uninstalled AVG and replaced it with Microsoft Security Essentials (Failed to work) In tools...

Column spacing problem
Every so often I have a problem with the location of text in adjacent columns. I'm currenly using Pub 2003 but I've had the same issue show up in 2000 (or maybe it was 2002). As the text flows from one column to the next, the text does not start at the top of the column. I've checked the "Format Text Box" dialog box and it's set for Top and the dimensions are the same as the next article and that text is fine. Any suggestions where to start? ----- JoAnn Two things are aesthetically perfect in the world - the clock and the cat. --Emile-August Char...

Problems balancing investment account.
I have a UBS account and download all transactions. I download the statement at the end of the month and balance the cash account. I find that some items that have been downloaded such as dividends do not show up on the statement. Example, the system downloaded a dividend for GE on March 15 that does not show up on the statement or UBS's website. The same holds true for some bill payments that show up on the statement but have not been downloaded. Example, a electronic payment I initiated at UBS to a the gas company on March 10 was not downloaded but shows up correctly on the UBS sta...

Custom drawing CListCtrl problem (with picture!)
I've got a CListCtrl that uses the custom data style to handle a massive amount of data, and I'm having wierd artifacts during custom drawing. I've tried several methods of drawing. The first I tried was completely overriding OnPaint: int iStart = GetTopIndex(); int iEnd = iStart + GetCountPerPage(); cprintf("Drawing range %d to %d (%d)\n", iStart, iEnd, iEnd-iStart); for(int i = iStart; i < iEnd; i++) { bSelected = GetItemState(i, LVIS_SELECTED) & LVIS_SELECTED; if(bSelected) { GetItemRect(i, &rItem, NULL); rItem.right = rClient.right; dc.F...

Outlook message problem
I have outlook 2000 and I cannot send messages (they just sit in my outbox). I have a mailbox setup which uses an exchange server on the LAN in the day and have a Dial-up ISP account which I use at night. I can receive email from my ISP but cannot send. If I use outlook express and set up mail account it works fine. I have tried to see what I've done wrong, but with no avail. Can somebody please advise me on the correct setup to use exchange on the LAN in the day and dialup ISP for my personal email account at night. Thanks ...

2003 Problem
I am reposting this because it was not answered: I jumped in to the middle of someone else Exchange setup. The users are printing emails and at the top of the page instead of having the users name it has /O First Organizational Unit/OU=First Administrative Group/CN=Recipients/CN=username That is certainly not normal. It looks like what you have is a fouled-up migration from another Exchange organization, but I can't really tell you more based on what you've posted. -- Ed Crowley MVP - Exchange "Protecting the world from PSTs and brick backups!" "Frank" ...

COUNTIF Problems
Hi, I have the following formula: =IF(ISERROR(COUNTIF(StatusCheck, "Snag Item")/COUNTIF(ElementCount,"Main Contractor - Builderswork")),0,COUNTIF(StatusCheck, "Snag Item")/COUNTIF(ElementCount,"Main Contractor - Builderswork")) Originally I had some problems getting ISERROR to work properly - but this is sorted now. The formula is supposed to count the number of times a snagging item is added into the spreadsheet (each snagging item has its own row) that is assigned a status of "Snag Item" and an Element of "Main -Contractor - B...

Winsock ... problem
Hi, I use MS. winsock activex control , I have a problem in geting data form the socket through winsock, I have writtem the following code : //////////////////////////////////////////////////////////////////////////// ///////////////////////// VARIANT d; COleVariant type,MaxLength; MaxLength.vt=VT_I4; MaxLength.lVal=5; type.vt=VT_BSTR; d.vt=VT_BSTR; WSock.GetData(&d,type,MaxLength); CString a= _com_util::ConvertBSTRToString(*d.pbstrVal);//to change BSTR to CString MessageBox(a); //////////////////////////////////////////////////////////////////////////// //////////////////...

printer problems
In Outlook Express I can not print the emain message while I am composing. I can only send it to myself and then print it. I am using a panasonic KX-P4400. Thanks ...

DrawText problem
Hi, I am using CDC::DrawText method, and in my input text I have the character "&". The problem is that this characters turns to a "_" character. Is there a way to fix it (without adding another "&" character to the existing one) ? Yoav. "Yoavo" <yoav@cimatron.co.il> wrote in message news:e$5E07CzHHA.3772@TK2MSFTNGP06.phx.gbl... > Hi, > I am using CDC::DrawText method, and in my input text I have the character > "&". > The problem is that this characters turns to a "_" character. > Is there a w...

Money Budget and Mortgage problems HELP!
I set up a budget with my mortgage payment. The problem is, th mortgage payment is acutally showing up on Special when I view th budget and I can't budget anything under special. How do I get th budget to recognize my mortgage so that I don't have to line items i budget one with zero target (special debt) and one with zero expense (debt loan) I am having the same problem. If you or anyone else figures out the answer, please let me know at chelly(remove this)@gci.net. THANK YOU! "marzomarz" wrote: > I set up a budget with my mortgage payment. The problem is, the &...

Access 2003 Form Wizard and Toggle Button Confusion/Problems
I am trying to use the Access 2003 Form Wizard to create a subform that will response to a toggle button that I created and to display that subform within my main form. However, I do not get the wizard window that is suppose to allow me to indicate that I want this to be a linked form so that it will appear within my main form (I see this example in a book that I have). Nor can I figure out how to manually create a link to that subform so that it is associated to the toggle buttion that I created so that it will appear within my main form. (I figured out how to write simple code so ...

Macbook Trackpad right click problem
Apple & Microsoft claim that they do not have the correct driver for MacBook Trackpad to run the full function eg. single click, double click on trackpad & right click function. Please anyone have any suggestions on third party driver is welcome. Thank you. I'm not sure what this has to do with CRM... but: The track pad functionality should all work If you have installed Apples BootCamp drivers. The drivers provided enable all the various hardware - trackpad, bluetooth and wireless, IR, volume and brightness controls etc. The drivers used to be downloadable from Apples sit...

Cd Burning Problems
I am trying to burn a few songs to an Audio CD-R in Windows Media, I have added them to the burn list, however the start burn button at the bottom of the pane does not light up for me to click it to actually start the burn.... Am i missing a step? This worked for me in the past and now i am ver confused? "betty" wrote: > I am trying to burn a few songs to an Audio CD-R in Windows Media, I have > added them to the burn list, however the start burn button at the bottom of > the pane does not light up for me to click it to actually start the burn.... &...

Problems, Problems
I recently installed Windows XP upgrade on my home computer. According to the instructions, all programs would be saved on the computer and work in Windows XP. This held true for my internet connections, favorites, documents etc, but I'm having problems with my email. Under my account name, I had to redo my internet settings, and while I can receive and send email now, I cannot access any of my old contacts, or emails saved in my inbox or other files! To make matters worse, when I try to open Outlook express under my hubby's account (the systems adminstrator on the compute...

Uninstall Sales for Outlook problem
I had to reinstall the server program because CRM trashed it. Now I have it up and running again but I can't install the Sales for Outlook because there is already an install there. When I try to uninstall it (in add/remove programs) it says that this action is only valid for products that are currently installed. How do I manually uninstall Microsoft CRM Sales for Outlook? I am trying so hard to use this program to see if it will be a benefit to customers but after 4 months on and off of trying to get it working, a am not sure I see the point. -- )))))))))))))))))))))))))))))))))...

Percentage problem
Hello, A record can belong to one of three groups and each record has a value attached to it. How can I calculate the total for each group as a percentage of the overall total? like 1 £33 33% 2 £33 33% 3 £33 33% ...

Fix for EXCHANGE to hotmail sending problem bdat
TURN OFF THE AUTO PROTECT FEATURE FOR INTERNET EMAIL IN THE SYMANTEC DESKTOP CLIENT THAT YOU INSTALLED ON YOUR EXCHANGE SERVER. IT MESSES UP BDAT ARGGGG!!!!!!! SOMETIMES I'M SUCH AN IDIOT!!! ...

class problem
He, I wrote the following code under //attributes: protected: BOOL m_bAdding; m_bAdding = FALSE; when I'm compiling it. It give me this error: C:\Documents and Settings\wouter\Mijn documenten\Rocket Administration\Rocket AdministrationView.h(32) : error C2501: 'm_bAdding' : missing storage-class or type specifiers Rocket AdministrationView.cpp C:\Documents and Settings\wouter\Mijn documenten\Rocket Administration\Rocket AdministrationView.h(32) : error C2501: 'm_bAdding' : missing storage-class or type specifiers Can someone help me out? Wouter do not initia...

Winsock
I posted this question previously , but no-one appeared to have any answer so I'm posting it again. Is there any examples of how to use a winsock in order to retrieve http from a website, and hopefully, send data back that would represent clicking on a button? I ideally want to be able to completely automate the process of logging on to the website, retrieving content as html text and, ideally, emulating the click of a button. I would like to use a winsock as it is apparently more customizable and reliable although I would use the internet transfer control if it's a lot easier. ...

Chart problem with dates
Hi, I am creating a chart that has week day information only, but when the chart is formed, the weekends are included. Is there a way to exclude the weekends? There is no weekend information in the chart data area. Thank you, Janel Hi, In order to exclude dates that do not have data you can set the axis to be categorical. This will plot a point for each date which will be equally spaced. Right click chart and pick Chart Options from the context menu. On the scale tab set the axis type to category. Cheers Andy Janel wrote: > Hi, > > I am creating a chart that has week da...

DrawThemeBackgroundEx ---- problem
Hi Our application, is a drawing software developed in MFC in VC6. My problem is that the application is crashing when i maximize the application in Windows XP theme. It works fine in XP in Windows classic theme. I traced out that uxtheme.dll ( C:\WINDOWS\system32 ), function DrawThemeBackgroundEx is deleting a pointer which i use in my application. I never call any function DrawThemeBackgroundEx.... How can i block the call to DrawThemeBackgroundEx??? Pls help >Our application, is a drawing software developed in MFC in VC6. > >My problem is that the application is crashing whe...

concatenate problem
Is it possible to base a concatenation for address labels off a query? A couple years ago you really helped me fix our address labels with concatenation, and I have used it for many things but always based off the same model. Now I need something a little different but I am running into a roadblock. Basing the concatenation off the query, I can get the address to show up properly (one address per concatenation, instead of four times if four people live at an address), but the names don't show up. There is no error message or anything, the concatenation field is just blank....