473,408 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

VB.NET 's IDispatch

well, how can i convert these code to VB.NET? thx

CallJScript(const CString strFunc, const CStringArray& paramArray)
{
CComPtr<IHTMLDocument2> m_spDoc;
m_spDoc.Attach( CHtmlView::GetHtmlDocument() );

//Getting IDispatch for Java Script objects
CComPtr<IDispatch> spScript;
m_spDoc->get_Script(&spDisp);

//Find dispid for given function in the object
CComBSTR bstrMember(strFunc);
DISPID dispid = NULL;
HRESULT hr = spScript->GetIDsOfNames(IID_NULL,&bstrMember,1,
LOCALE_SYSTEM_DEFAULT,&dispid);
if(FAILED(hr))
{
ShowError(GetSystemErrorMessage(hr));
return false;
}

const int arraySize = paramArray.GetSize();
//Putting parameters
DISPPARAMS dispparams;
memset(&dispparams, 0, sizeof dispparams);
dispparams.cArgs = arraySize;
dispparams.rgvarg = new VARIANT[dispparams.cArgs];
dispparams.cNamedArgs = 0;

for( int i = 0; i < arraySize; i++)
{
CComBSTR bstr = paramArray.GetAt(arraySize - 1 - i); // back reading
bstr.CopyTo(&dispparams.rgvarg[i].bstrVal);
dispparams.rgvarg[i].vt = VT_BSTR;
}
EXCEPINFO excepInfo;
memset(&excepInfo, 0, sizeof excepInfo);
CComVariant vaResult;
UINT nArgErr = (UINT)-1; // initialize to invalid arg
//Call JavaScript function
hr = spScript->Invoke(dispid,IID_NULL,0,
DISPATCH_METHOD,&dispparams,
&vaResult,&excepInfo,&nArgErr);
delete [] dispparams.rgvarg;
if(FAILED(hr))
{
ShowError(GetSystemErrorMessage(hr));
return false;
}
return vaResult;
}

Jul 19 '05 #1
0 2866

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Peter Sparago | last post by:
I am working with the MSHTML editor control. I used win32com.client.gencache.EnsureModule on the MSHTML type library to generate the necessary IDispatch support for all the various interfaces used...
3
by: Roger That | last post by:
Hi, I am trying to use the function "CreateStreamOnHGlobal" from python code (I need to pass an IStream object to MSXML, like I do in C++ code). I was able to retrieve a pointer on the IStream...
5
by: Dominic Godin | last post by:
Hi, I have decleared the IDispatch interface but I'm having trouble using it. Word.Application MSWord = new Word.ApplicationClass(); IDispatch wb = (IDispatch)MSWord.WordBasic; int lcid =...
1
by: Dmitry Medvedev | last post by:
Hello, I need to write C# class, that would implement IDispatch interface to be used in ActiveScript. I can't use IReflect interface here due to design issues, I need to handle GetIDsOfNames...
4
by: Phil Coveney | last post by:
Hello, I am implementing a class in C# that wraps an automation server and am stuck on something basic. Using the following code fragment: using System; using System.Runtime.InteropServices;...
8
by: Charles Law | last post by:
Hi guys There's nothing much going on in Interop at the moment, so I'll post this here as well in case someone can give me a quick answer. The following is an extract from MSDN: <extract>...
0
by: Jim Hubbard | last post by:
How would I implement the IDispatch interface to handle the following in VB.Net <BEGIN> Controlling Download and Execution The WebBrowser Control gives you control over what it downloads,...
4
by: eselk | last post by:
I've got an out-of-process COM server (EXE) that I want to be able to control from Visual Basic. I can already control it from a C/C++ app without any issues. Under VBA in MS Access 2000, which I...
3
by: Huayang Xia | last post by:
I am trying to use ctypes to call dll functions. One of the functions requires argument "struct IDispatch* ". I do have a PyIDispatch object in python. How can I convert this "PyIDispatch object"...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.