com

Delphi CreateOleObject events

不想你离开。 提交于 2019-12-01 00:02:31
There is a code: var myobject: OleVariant; begin myobject := CreateOleObject('SomeNamespace.SomeClass'); end; This COM object has events (for example OnClick). How should I connect to these events without importing TLB? You are working with COM late-binding, so do you need write a lot of code to handle events. this task is not difficult if you know COM, basically do you need follow these steps. Create a new object(class) derived from TInterfacedObject that implements IDispatch implement the Invoke() function of your new class Query for the connection point container ( IConnectionpointContainer

Outlook Object Model - Detecting if email has been sent

不羁的心 提交于 2019-11-30 23:46:03
I have the following code in my test Delphi 2006 BDS application: procedure TForm1.Button1Click(Sender: TObject); const olMailItem = 0; var Outlook: OleVariant; vMailItem: variant; begin Outlook := CreateOleObject('Outlook.Application'); vMailItem := Outlook.CreateItem(olMailItem); try vMailItem.Recipients.add('anemailaddress@gmail.com'); vMailItem.Display(True); -- outlook mail message is displayed modally except end; VarClear(Outlook); end; I need to be able to detect whether the user sent the email from within the outlook screen. I tried the following code: if vMailItem.Sent then ... But

How to compare BSTR against a string in c/c++?

你说的曾经没有我的故事 提交于 2019-11-30 23:21:01
问题 wprintf(L"Selecting Audio Input Device: %s\n", varName.bstrVal); if(0 == strcmp(varName.bstrVal, "IP Camera [JPEG/MJPEG]"))... The above reports : error C2664: 'strcmp' : cannot convert parameter 1 from 'BSTR' to 'const char *' 回答1: You have to use wcscmp instead: if(0 == wcscmp(varName.bstrVal, L"IP Camera [JPEG/MJPEG]")) { } Here is a description of the BSTR data type, it has a length prefix and a real string part which is just an array of WCHAR characters. It also has 2 NULL terminators.

com4j on Windows 64 bit

回眸只為那壹抹淺笑 提交于 2019-11-30 23:01:33
I've downloaded the latest com4j jars and I'm trying to run through the most simple of their examples. I'm on Windows 7 64 bit and using a 64 bit JVM. When I run the command (from the com4j tutorial): java -jar tlbimp.jar -o wsh -p test.wsh %WINDIR%\system32\wshom.ocx I get: Exception in thread "main" java.lang.UnsatisfiedLinkError: com4j-amd64.dll: %1 is not a valid Win32 application at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(Unknown Source) at java.lang.ClassLoader.loadLibrary(Unknown Source) at java.lang.Runtime.load0(Unknown Source) at

Exposing COM events to VBScript (ATL)

旧城冷巷雨未停 提交于 2019-11-30 23:01:24
I have built a COM server DLL in C++ with ATL by using the "ATL simple object" wizard. I followed Microsoft's ATLDLLCOMServer example. Everything works well except for one thing: I do not receive COM events in VBScript . I do receive the events in C#. I had events working in VBScript in an earlier MFC-based implementation as ActiveX control. My control is defined like this: class ATL_NO_VTABLE CSetACLCOMServer : public CComObjectRootEx<CComSingleThreadModel>, public CComCoClass<CSetACLCOMServer, &CLSID_SetACLCOMServer>, public IConnectionPointContainerImpl<CSetACLCOMServer>, public CProxy

Can't get all excel processes to stop when closing through Powershell

时光总嘲笑我的痴心妄想 提交于 2019-11-30 22:54:10
With this code, I am opening excel(with visible = false so the user cannot see it), writing to a workbook, and then either opening excel(making it visible) after the script ends or closing it completely without saving. When I save excel, leave it open, end the script, and then manually close excel later, there are no background processes in the task manager. However, when I close excel with the script, it remains in the task manager. Here is how I start excel: $script:excel = new-object -ComObject excel.application # create excel object $excel.visible = $false # hide excel window $script

shared_ptr vs CComPtr

流过昼夜 提交于 2019-11-30 22:45:25
I'm somewhat used to the concept of refcounting through COM and I'm somewhat new to shared_ptr. There are several nice properties with CComPtr that I don't find in shared_ptr, and I'm wondering what are the pattern that prevent missuse of shared_ptr. The AddRef/Release pattern guarantees there is only one refcount per object (the refcount is stored on the object itself), so it's safe, when you have a random pointer to create a CComPtr around it. On the other hand, shared_ptr has a separate refcount pointer, so it's unsafe to create a new shared_ptr on an object (why does the standard provide a

Register ActiveX exe server using WiX

吃可爱长大的小学妹 提交于 2019-11-30 22:39:29
I have several VB6 ActiveX server exe files which need to be registered on install before they can be used. I have tried using Heat to extract the information but it only generates a file element. These files can be registered by calling them with the /regserver switch and unregister by calling them with the /unregserver switch. I understand this is not the correct way to this. Instead I should add the registry keys and other required elements to my wix source. My question is how do I find out what registry keys and other element I require to register these ActiveX exe files. Seeing as Heat

Use .NET in VB6 or classical ASP

允我心安 提交于 2019-11-30 22:10:14
Duplicate of Calling .NET methods from VB6 via COM visible DLL Which ways exist to use/call .NET classes/functions/libraries (.net 3.x) in VB6 or classical ASP ? Has anybody experiences with that ? How much effort is necessary to wrap .NET to COM ? Are there tools which help ? It's pretty easy actually and I have created .NET components called from both VB6 COM dlls and Classic ASP. You essentially need to create a COM callable wrapper thats exposes the .NET component to a COM client. This article will get you started Calling a .NET component from a COM component A couple of pointers Any COM

return array from com object

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-30 22:07:52
问题 I want to pass a list of alarm names from COM to VBScript used in ASP pages. If the method name is GetAlarms , What would be the signature of the method?. The number of alarms returned by GetAlarms will vary. Does VBScrip support Safe Array? 回答1: The declaration in the *.idl file would look like this: [id(1)] HRESULT GetAlarms([out,retval] SAFEARRAY(VARIANT)* pAlarms); The corresponding C++ method would look like this: STDMETHODIMP CMyClass::GetAlarms(SAFEARRAY** pAlarms) { CComSafeArray