com

How to use PowerShell to access methods and properties of a Third-Party OLE DLL?

半世苍凉 提交于 2019-12-22 10:54:35
问题 I am trying to write a PowerShell script which could access methods and properties of a third-party OLE DLL. The software vendor provided a working example in vbscript to achieve the same result. Below is an excerpt of the codes: Set objOLE = CreateObject("NETIQOLE.APPMANAGER") objOLE.Logon strInstance, strRepository, strUserID, strPwd ... However, when I tried to code in PowerShell as below: $objOLE = New-Object -ComObject "NETIQOLE.APPMANAGER" $objOLE | Get-Member I got output below and

Problem creating COM-library only containing enum's

馋奶兔 提交于 2019-12-22 10:46:00
问题 I'm am doing a COM-interop project. Substituting some VB and C++ ATL COM projects with C# and .NET Interop. When i define enumerations in .NET and they are made ComVisible, they get exposed as Typelib.EnumType_EnumValue enstead of just Typelib.EnumValue. The typelib exporter does this to ensure that the value names are unique. But i know that all my enum's are unique, so i don't want the underscores. Also there is a lot of client code that needs alteration if i don't get rid of the

How do I render the scrollable regions of a canvas with IViewObject::Draw?

浪尽此生 提交于 2019-12-22 10:43:55
问题 I've been trying to render the entire canvas in an IWebBrowser2 control to a bitmap. IViewObject::Draw seems to be the most promising approach, but I can't get it to render anything that would requires a scroll to show. While I could automate the scrolling and stitch the images together, this would look weird with any fixed position elements. Is this even doable? Additionally, I've tried to set the controller's size to one that would allow the entire contents to display without needing to

How to make stdcall from Go

二次信任 提交于 2019-12-22 10:24:10
问题 I have a pointer to a COM interface and would like to take the function pointers from its virtual table and make method calls. To do this I need to make stdcall method calls. In Go how do I make a call with convention stdcall or make a call with convention stdcall in cgo? 回答1: See "godoc syscall Proc" for instructions on how to call stdcall functions on windows. Be warned that *Proc.Call does allocate / deallocate memory, so, if you care about efficiency, you should use correspondent syscall

How to make stdcall from Go

。_饼干妹妹 提交于 2019-12-22 10:21:35
问题 I have a pointer to a COM interface and would like to take the function pointers from its virtual table and make method calls. To do this I need to make stdcall method calls. In Go how do I make a call with convention stdcall or make a call with convention stdcall in cgo? 回答1: See "godoc syscall Proc" for instructions on how to call stdcall functions on windows. Be warned that *Proc.Call does allocate / deallocate memory, so, if you care about efficiency, you should use correspondent syscall

Passing objects from C# to VBA using COM Interop

半世苍凉 提交于 2019-12-22 09:47:51
问题 Is it possible to pass a custom object (like MyClass[]) from C# to VBA using COM? If not, which is the best solution to get this working? 回答1: I assume you're talking about Excel VBA to C# ... here's a minimal C# class that does it, in a project w default name ClassLibrary1: using System; using System.Runtime.InteropServices; namespace Tester { [ClassInterface(ClassInterfaceType.AutoDual)] public class TestClass { public double D { get; set; } // simple property to get, set a double public

Pass a buffer of chars from .NET to COM and get it back updated

怎甘沉沦 提交于 2019-12-22 09:39:40
问题 I have the following COM method to be called from C#, which returns a string in the provided buffer pchText (which is not necessarily zero terminated) and the number of characters copied in pcch : HRESULT Next([in, out] long* pcch, [out, size_is(*pcch)] OLECHAR* pchText); How do I define the C# signature for interop? So far, I tried this: void Next(ref int pcch, [MarshalAs(UnmanagedType.LPWStr, SizeParamIndex = 0)] System.Text.StringBuilder pchText); It appears to work, but I am not sure if

CoCreateInstance exact match in .NET?

天大地大妈咪最大 提交于 2019-12-22 09:39:32
问题 I have in-proc (DLL) COM Server, but I settled in to run as DllSurrogate, for this reason from unmanaged code (Delphi) i have: function TComWrapper.GetServer: IUnknown; begin OleCheck(CoCreateInstance(ServerData^.ClassId, nil, CLSCTX_LOCAL_SERVER, IUnknown, Result)); end; from C# am using now: [DllImport("ole32.dll", EntryPoint = "CoCreateInstance", CallingConvention = CallingConvention.StdCall)] static extern UInt32 CoCreateInstance([In, MarshalAs(UnmanagedType.LPStruct)] Guid rclsid, IntPtr

System.String[*] and System.String[] Difference in C#

人走茶凉 提交于 2019-12-22 09:24:12
问题 Edit : I know that C# equivalent of For Each server As String In servers is foreach(var item in servers) but since GetOPCServers returns object, it should be cast to iterable type. I am developing an application using a COM library. Since 64bit causes problems, my target CPU x86. All methods works as expected, except GetOPCServers() . Although Visual Basic code using same dll does not cause problem, C# throws System.InvalidCastException saying that: A first chance exception of type 'System

System.String[*] and System.String[] Difference in C#

自闭症网瘾萝莉.ら 提交于 2019-12-22 09:23:51
问题 Edit : I know that C# equivalent of For Each server As String In servers is foreach(var item in servers) but since GetOPCServers returns object, it should be cast to iterable type. I am developing an application using a COM library. Since 64bit causes problems, my target CPU x86. All methods works as expected, except GetOPCServers() . Although Visual Basic code using same dll does not cause problem, C# throws System.InvalidCastException saying that: A first chance exception of type 'System