473,382 Members | 1,441 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,382 software developers and data experts.

IDispatch GetIDsFromNames

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 = System.Globalization.CultureInfo.CurrentCulture.LC ID;

string[] rgsNames = {"DisableAutoMacros"};
int[] rgDispId;
Guid nullGUID = Guid.Empty;

int result = wb.GetIDsOfNames(ref nullGUID, rgsNames, 2,
lcid, out rgDispId);

This code sets the result to -1073741819. I can find next to no info on
this error code. Also the rgDispId stays null. What I'm I doing wrong?
Any Ideas?

Dominic Godin
Nov 16 '05 #1
5 3374
Dominic,
This code sets the result to -1073741819. I can find next to no info on
this error code. Also the rgDispId stays null. What I'm I doing wrong?
Any Ideas?


Can you post your IDispatch declaration?

You seem to have one level of indirection too much on the last
parameter, it shouldn't be ref/out since arrays are reference types.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #2
Thanks

public interface IDispatch
{
[PreserveSig] int GetTypeInfoCount();
UCOMITypeInfo GetTypeInfo(
[MarshalAs(UnmanagedType.U4)] int iTInfo,
[MarshalAs(UnmanagedType.U4)] int lcid);
[PreserveSig] int GetIDsOfNames(
ref Guid riid,
string[] rgsNames,
[MarshalAs(UnmanagedType.U4)] int cNames,
[MarshalAs(UnmanagedType.U4)] int lcid,
int[] rgDispId); // this was out, tried ref. Both set
// the array to null
[PreserveSig] int Invoke(
int dispIdMember,
ref Guid riid,
[MarshalAs(UnmanagedType.U4)] int lcid,
[MarshalAs(UnmanagedType.U4)] int dwFlags,
ref DISPPARAMS pDispParams,
[Out] object[] pVarResult,
ref EXCEPINFO pExcepInfo,
[Out] IntPtr[] pArgErr);
}

With the out removed this still returns an error of -1073741819 and
leaves the rgDispId array untouched.
Mattias Sjögren <ma********************@mvps.org> wrote in
news:Oa**************@TK2MSFTNGP09.phx.gbl:
Dominic,
This code sets the result to -1073741819. I can find next to no info
on this error code. Also the rgDispId stays null. What I'm I doing
wrong? Any Ideas?


Can you post your IDispatch declaration?

You seem to have one level of indirection too much on the last
parameter, it shouldn't be ref/out since arrays are reference types.

Mattias


Nov 16 '05 #3
Thanks

[Guid("00020400-0000-0000-c000-000000000046")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown )]
public interface IDispatch
{
[PreserveSig] int GetTypeInfoCount();
UCOMITypeInfo GetTypeInfo(
[MarshalAs(UnmanagedType.U4)] int iTInfo,
[MarshalAs(UnmanagedType.U4)] int lcid);
[PreserveSig] int GetIDsOfNames(
ref Guid riid,
string[] rgsNames,
[MarshalAs(UnmanagedType.U4)] int cNames,
[MarshalAs(UnmanagedType.U4)] int lcid,
ref int[] rgDispId); // I was using out
[PreserveSig] int Invoke(
int dispIdMember,
ref Guid riid,
[MarshalAs(UnmanagedType.U4)] int lcid,
[MarshalAs(UnmanagedType.U4)] int dwFlags,
ref DISPPARAMS pDispParams,
[Out] object[] pVarResult,
ref EXCEPINFO pExcepInfo,
[Out] IntPtr[] pArgErr);
}

Still doesn't work mind. Still get the -1073741819 error and the
rgDispId array is left untouched. Any ideas?

PS. Using a crappy newserver so sorry if this is a double post.

Mattias Sjögren <ma********************@mvps.org> wrote in
news:Oa**************@TK2MSFTNGP09.phx.gbl:
Dominic,
This code sets the result to -1073741819. I can find next to no info
on this error code. Also the rgDispId stays null. What I'm I doing
wrong? Any Ideas?


Can you post your IDispatch declaration?

You seem to have one level of indirection too much on the last
parameter, it shouldn't be ref/out since arrays are reference types.

Mattias


Nov 16 '05 #4
[PreserveSig] int GetIDsOfNames(
ref Guid riid,
string[] rgsNames,
[MarshalAs(UnmanagedType.U4)] int cNames,
[MarshalAs(UnmanagedType.U4)] int lcid,
ref int[] rgDispId); // I was using out


It shouldn't be ref either, try it like this

[PreserveSig] int GetIDsOfNames(
ref Guid riid,
[MarshalAs(UnmanagedType.LPArray,
ArraySubType=UnmanagedType.LPWStr)]
string[] rgsNames,
int cNames,
int lcid,
[MarshalAs(UnmanagedType.LPArray)] int[] rgDispId);

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #5
That did the trick, thank you ever so much.

Final interface was:

[Guid("00020400-0000-0000-c000-000000000046")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown )]
public interface IDispatch
{
[PreserveSig] int GetTypeInfoCount();
UCOMITypeInfo GetTypeInfo(
[MarshalAs(UnmanagedType.U4)] int iTInfo,
[MarshalAs(UnmanagedType.U4)] int lcid);
[PreserveSig] int GetIDsOfNames(
ref Guid riid,
[MarshalAs(UnmanagedType.LPArray,
ArraySubType=UnmanagedType.LPWStr)]
string[] rgsNames,
int cNames,
int lcid,
[MarshalAs(UnmanagedType.LPArray)] int[] rgDispId);
[PreserveSig] int Invoke(
int dispIdMember,
ref Guid riid,
[MarshalAs(UnmanagedType.U4)] int lcid,
[MarshalAs(UnmanagedType.U4)] int dwFlags,
ref DISPPARAMS pDispParams,
[MarshalAs(UnmanagedType.LPArray)][Out] object[]
pVarResult,
ref EXCEPINFO pExcepInfo,
[MarshalAs(UnmanagedType.LPArray)][Out] IntPtr[]
pArgErr);
}

Thanks again.

Dominic Godin

Nov 16 '05 #6

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...
0
by: | last post by:
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(...
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"...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.