com

activex in winform

喜欢而已 提交于 2019-12-22 13:58:48
问题 I need to put some activeX in my .Net WinForm. The provider had sent me a .tlb and the com .dll. Is this enough? How do I put it on winform? 回答1: That should be sufficent. You'll need to register that dll on your machine, add it to the dev studio Toolbox (Right click on the toolbox/Choose Items) and go to the COM tab, if you can't find it in there you can browse to the specific location and select the Type Library to use. After that you can just drag the new control to your form. A Reference

How to import and use a unmanaged C++ class from C#?

会有一股神秘感。 提交于 2019-12-22 13:39:08
问题 I have an native C++ dll, some header files and the import library. Is there a way how to instantiate an object within C# that is defined in the dll? The two ways I'm aware of are: to wrap the C++ code into COM to use DLLImport and external C functions 回答1: C++/CLI is your friend for this. You'll run into one problem though: it is not possible to store standard C++ objects inside C++/CLI ref or value classes (the ones for .NET). So you'll have to resort to the following class (that you can

COM interop passing wrong pointers, with only a single byte of my data

寵の児 提交于 2019-12-22 12:45:29
问题 I'm having a problem passing pointers to native code using COM. I want to build up a byte array in managed (C#) code and pass that array to native (C++) code. I'm handling the managed-code side, and my colleague owns the native side. Note that I'm much stronger on the managed side, and I've pretty much been using the COM object as written. The COM signature (simplified) looks this: unsafe void DoSomething([In] byte* buffer, [In] uint length) And I call it like this: var arr = File

WUA API unable to uninstall updates

孤街醉人 提交于 2019-12-22 12:38:43
问题 I have encountered an issue when using Windows Update Agent (WUA) API. Whenever I try to uninstall an update using IUpdateInstaller.IsForced := True; IUpdateInstaller.BeginUninstall(... i'm getting WU_E_UNINSTALL_NOT_ALLOWED ( The update could not be uninstalled because the request did not originate from a WSUS server ). Does it mean that I can't use WUA API to uninstall updates? In that case, why are BeginUninstall/Uninstall methods there? 回答1: According to Hey, Scripting Guy! How Can I

Register a proxy/stub in HKEY_CURRENT_USER

醉酒当歌 提交于 2019-12-22 11:47:50
问题 The MIDL compiler generates code for a proxy/stub with registration routines that write to HKEY_LOCAL_MACHINE. Is there any way (preferably without hacking the MIDL-generated code and without bypassing all that generated code in favor of custom code) to register a MIDL-generated p/s in HKEY_CURRENT_USER? Also: Will this work if both the p/s and the COM server are registered per-user like this? I just found (after a very frustrating 48 hours) that a p/s registered machine-wide will not work

How to check ErrorCode for REGDB_E_CLASSNOTREG?

那年仲夏 提交于 2019-12-22 11:37:17
问题 try { // call to Com Method } catch (COMException e) { if (e.ErrorCode == 0x80040154) // REGDB_E_CLASSNOTREG. { // handle this error. } } I would like to check if com exception is thrown due to REGDB_E_CLASSNOTREG then handle it. I tried with the code above but it gives warning: Comparison to integral constant is useless; the constant is outside the range of type 'int' I believe this error is due to 0x80040154 is not in Int32 range. Can you suggest any possible solution? or Is there any other

How to un-select cells in Excel? Using Matlab to create a chart adds graph with value of makred area

安稳与你 提交于 2019-12-22 11:36:10
问题 Excel 2016 remembers the cells you "marked" (selected) last before closing the file and the same asrea will be marked at the next opening of the file. The only way to not mark an area is an untouched file created by for example Matlab. How to unmark all areas in Excel using Matlab? In my program (code below) I access an existing Excel File using Matlab. The code creates a new chart with set range. Unfortunately there are always created more graphs in the chart and selecet in range. To be more

Convert VARIANT to…?

扶醉桌前 提交于 2019-12-22 11:26:55
问题 Note: Attempting to invoke a method of an interface, of which the return type is _variant_t Code: _variant_t resultsDataString; _bstr_t simObjectNames; simObjectNames = SysAllocString (L"TEST example 3"); resultsDataString = pis8->GetSimObject (simObjectNames); inline function illustrated below, contained in .tli FILE: inline _variant_t IS8Simulation::GetSimObject ( _bstr_t Name ) { VARIANT _result; VariantInit(&_result); HRESULT _hr = get_SimObject(Name, &_result); if (FAILED(_hr)) _com

Exactly what are these _B_var_Xxxxx and _B_str_Xxxxx members in the VBA COM libraries?

北慕城南 提交于 2019-12-22 11:17:53
问题 Imagine the following function call: foo = UCase("bar") I'm parsing this code, and determine that UCase is a function call; now I want to resolve that function call to the declaration of the function in the COM library it's defined in. The idea is to implement a code inspection that determines when a Variant built-in function is used when a String -returning function exists, like here UCase$ could be used instead. It seems the functions I'm after are declared as _B_var_Ucase and _B_str_UCase

Allowed “out” parameter types in a COM automation interface

删除回忆录丶 提交于 2019-12-22 10:57:05
问题 I'm implementing COM automation (dual interface) for an application. The automation interface will be called from VBScript. I'm not quite clear on what types are allowed for the method's arguments. I do know that basically values have to fit in a VARIANT , but does that mean every parameter of type int must be passed through a VARIANT , or can one pass int directly? For example, two methods I have in my MIDL file are: HRESULT SetDate([in] int Year, [in] int Month, [in] int Day); HRESULT