Link to home
Start Free TrialLog in
Avatar of yzmao
yzmaoFlag for United States of America

asked on

How to use Inet.OpenURL method in Visual C++?

I try to use Microsoft Internet Transfer Control (Inet, as COM component) in my VC application program, but have difficulty to get OpenURL method right. In the wrapping class CInet, this method is defined as:

VARIANT CInet::OpenURL(const VARIANT& URL, const VARIANT& DataType)

How to supply the second parameter? -- I can't find example, and I don't know what "DataType" means.

Note: Please no VB solution; also, CInet::OpenURL seems different from OpenURL in WinInet API (I don't need this).
Avatar of Brain2000
Brain2000
Flag of United States of America image

VARIANT CInet::OpenUrl(const VARIANT &url [, const VARIANT &datatype])

The settings for datatype are:

icString (0)
 This is the default. Retrieves data as string.

icByteArray (1)
 Retrieves data as a byte array.

The OpenURL method's return value depends on the target of the URL. For example, if the target URL is the directory of an FTP server, the directory will be returned. On the other hand, if the target is a file, the file will be retrieved.
Avatar of yzmao

ASKER

Thanks Brain2000.

Is icString or icByteArray Visual Bacic concepts? -- I can't use either as a parameter("not defined").

Would you please tell me how I can call the function actually when using them as parameters?

-- the following will not compile:

varHTML = m_ctrInet.OpenURL(varURL, icString);

--"icString not defined".
icString is defined as a 0 and icByteArray is defined as a 1, if I'm not mistaken.  You should be able to make a variant with either the value 0 or 1 and it should work.
Avatar of yzmao

ASKER

Hi,

Thanks for your response. Actually, it doesn't work. The compile says I can't convert "const int" to "const struct tagVARIANT" when I use 0 or 1 as the parameter.

PLease notice that, as I said before, icString, icByteArray are VB concepts -- when used in VB call, they are OK; but not in VC++. What I need is a parameter for VC++ Inet.OpenURL call (the parameter should be "const struct tagVARIANT").

You may have a try.

Yours,

yzmao
Avatar of yzmao

ASKER

Adjusted points to 200
Hi, I'm back from the weekend.

The reason that your second argument wasn't working is because you can't send a straight 0 or 1.  thus the error "can't convert const int to const struct tagVARIANT".  You must send the 0 or 1 as a VT_I4 variant, which is a 4 bytes integer.
Avatar of yzmao

ASKER

Thanks, Brain2000. It works now.

yzmao
ASKER CERTIFIED SOLUTION
Avatar of Brain2000
Brain2000
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial