com

How can I add functionality to COM object in c#?

元气小坏坏 提交于 2019-12-25 18:31:38
问题 I am new to COM and c# and I would like to add functionality to a COM object that is exposed by a third-party program. Initially my intention was to inherit from the COM object class, but I found out it was not so straight forward (for example here). Presently, I have two interfaces (namely IComAuto and ComAuto ) and an associated class ( ComAutoClass ). To add my custom methods to ComAuto objects, I have created a class ComObjectWrapper that inherits from this interface and implements it by

get file name from IShellItem in IfileOperation.GetDisplayName

為{幸葍}努か 提交于 2019-12-25 13:09:09
问题 I hooked the CopyItems method of IFileOperation to monitor/intercept file copy in windows. My problem is how can i retrieve the full file name from IShellItem (last param of CopyItems) function New_CopyItems(p: Pointer; punkItems: IUnknown;psiDestinationFolder: IShellItem): HResult; stdcall; The psiDestinationFolder have a method called GetDisplayName that return only the folder name of current file was begin copied!! But i want to get full file name and don't know what i should to do !?

Use PowerShell to create instance of COM object

浪尽此生 提交于 2019-12-25 09:27:10
问题 I'm trying to use SAP/BusinessObjects' Universe Design Tool (UDT) in a PowerShell session. I registered the type library: C:\> C:\Windows\Microsoft.NET\Framework\v4.0.30319\regtlibv12.exe "C:\Program Files (x86)\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\win32_x86\designer.tlb I attempted to create an instance of the Designer in PowerShell directly: PS> $app = New-Object -ComObject Designer.Application System.__ComObject The instance doesn't have any of the expected properties

Unable to set Comobject Value

余生颓废 提交于 2019-12-25 09:16:12
问题 I have a snippet of code that opens a word template, then attempts to set values of named FormFields. $options = @{ 'foo' ='bar'; 'bizz' = 'buzz'; } $document = 'C:\Form_template.doc' $word = new-object -ComObject Word.application $doc = $word.Documents.Open($document) $word.visible = $true $fields = $doc.FormFields $fields.item('foo').Result = $options['foo'] $fields.item('bizz').Result = $options['bizz'] When running this snippet, the form fields are not set properly. However, when I run

Microsoft Word Interop: SaveAs hangs for some misterious argument types

梦想与她 提交于 2019-12-25 09:09:57
问题 When trying to simplify a PowerShell script that converts from Word to PDF, I found out the following weird scenario that blows my mind. Here's the transcript from a proof of concept interactive session: Windows PowerShell Copyright (C) 2016 Microsoft Corporation. All rights reserved. PS C:\Users\Frag> Add-Type -AssemblyName Microsoft.Office.Interop.Word PS C:\Users\Frag> $word = New-Object -ComObject Word.Application PS C:\Users\Frag> $i = Get-Item ".\document.docx" PS C:\Users\Frag> $i

Showing custom file properties in the Windows Explorer file hover tooltip

自闭症网瘾萝莉.ら 提交于 2019-12-25 09:03:57
问题 I have used the DSOFile library, available within the Microsoft Developer Support 2.1 OLE File Property Reader 2.1 sample to set a custom file property for a file (sidenote, the sample has been updated in version 2.1 to handle non-OLE files, such as the new Office 2007 file formats, if a custom property handler is available): SetCustomProperty(@"C:\Users\User\Desktop\Example.doc", "CustomProperty", "CustomValue"); public static void SetCustomProperty(string filename, string key, object value)

How to catch a pywin32com exception on opening files

主宰稳场 提交于 2019-12-25 08:57:40
问题 I am trying to open an excel file in python using COM, and trying to catch the file not found error: I first tried catching the IOError: try: output = xl.Workbooks.Open(Params.workbookName) except IOError as reason: print reason exit() But COM doesn't raise an IO Error when it has a file not found problem, instead it raises something called com_error: com_error: (-2147352567, 'Exception occurred.', (0, u'Microsoft Office Excel', u"'asdf.xlsx' could not be found. Check the spelling of the file

Handling COM Callbacks in C# Client

孤人 提交于 2019-12-25 08:19:35
问题 Here is how the application is designed - I have a COM server raising events on certain conditions. I have a C# client UI which is supposed to handle these events raised by this COM server. There is a delegate in my C# client which I pass to the COM server and it calls back on an event. I have a custom wrapper which marshals the delegate as function pointer. Like so... Fxn1inCOMWrapper([In, MarshalAs(UnmanagedType.FunctionPtr)] Client.SetStatusDelegate StatusCallback); The callback mechanism

Inconsistent ComObject property behavior

做~自己de王妃 提交于 2019-12-25 07:48:59
问题 I previously asked a question about setting ComObject property values, and found irregular behavior when setting ComObject property values. $options = @{ 'foo' ='bar'; 'bizz' = 'buzz'; } $document = 'C:\Form_template.doc' $word = new-object -ComObject Word.application $doc = $word.Documents.Open($document) $word.visible = $true $fields = $doc.FormFields I can attempt to set the value of the FormField in three ways, and the behavior is different than I would anticipate. PS C:\>#Attempting to

Error 80070005 - I Can't find Microsoft Excel Application or CLSID {00024500-0000-0000-C000-000000000046} on DCOM

我与影子孤独终老i 提交于 2019-12-25 07:48:09
问题 After getting enlightenment from this post , i've changed the flow. I asked the user to upload the excel so i can manipulate it later. and then i got error : Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005. You can see the screenshot here : https://twitter.com/itsCYD/status/570134973128302592/photo/1 i googled for solution and found this : https://waheedrous.wordpress.com/2014/01/26/error-office