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).
yzmaoAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Brain2000Connect With a Mentor Commented:
Excellent.  Glad you got it working.
0
 
Brain2000Commented:
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.
0
 
yzmaoAuthor Commented:
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".
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Brain2000Commented:
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.
0
 
yzmaoAuthor Commented:
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
0
 
yzmaoAuthor Commented:
Adjusted points to 200
0
 
Brain2000Commented:
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.
0
 
yzmaoAuthor Commented:
Thanks, Brain2000. It works now.

yzmao
0
All Courses

From novice to tech pro — start learning today.