com

Get AdministratorsMembers SIDs in .NET CORE 2

≡放荡痞女 提交于 2021-01-27 14:00:51
问题 I wrote this function to retrieve all Administrators Members SIDs: private IList<byte[]> GetAdministratorsMembersSIDs() { IList<byte[]> adminMembers = new List<byte[]>(); SecurityIdentifier id = new SecurityIdentifier(administratorsSid); string name = id.Translate(typeof(NTAccount)).Value.Split('\\')[1]; using (DirectoryEntry adminGroupEntry = new DirectoryEntry(string.Format("WinNT://./{0},group", name))) { foreach (object member in (IEnumerable)adminGroupEntry.Invoke("Members")) { using

Powershell - add catch to pick up if there are no Excel processes

我怕爱的太早我们不能终老 提交于 2021-01-27 13:20:41
问题 Is there way to add an if/else catch to only $excelId = get-process excel | %{$_.Id} | ?{$before -notcontains $_} if there is no excel process running? e.g. if Excel is running then get-process id, if not then ignore it. Get-Process : Cannot find a process with the name "excel". Verify the process name and call the cmdlet again. At run.ps1:3 char:24 + $before = @(get-process <<<< excel | %{$_.Id} ) + CategoryInfo : ObjectNotFound: (excel:String) [Get-Process], ProcessCommandException +

combase error (CoInitialize has not been called)

时光总嘲笑我的痴心妄想 提交于 2021-01-27 12:50:30
问题 onecore\com\combase\objact\objact.cxx(812)\combase.dll!00007FF8BD322169: (caller: 00007FF8BD320F78) ReturnHr(1) tid(b54) 800401F0 CoInitialize has not been called. I'm using Visual Studio 2015 and have started receiving the following error message. I'm not trying to write dll's or using COM objects or whatever. It's just a simple OpenGL program. I have no idea where this error message has come from. How do I get rid of it? 回答1: You are using COM implicitly. Without code, we don't know exacly.

How do I export an interface written in C# to achieve Delphi code generated by TLB

馋奶兔 提交于 2021-01-27 12:28:46
问题 I'm currently developing a "drop-in" replacement of an old COM interface (which is used to communicate with other devices). This interface is currently used in a big application. The old COM interface is now deprecated by the author of the library they now only support and develop a C# interface. My task is to develop the above mentioned "drop-in" replacement. Which acts as a proxy between the old application (written in Delphi) and the new C# based interface. Im trying to have as little as

Call non-default constructor of COM class

我是研究僧i 提交于 2021-01-27 07:59:07
问题 I have a DLL (written in C#) containing a class with 2 Constructors; a default (no arguments) constructor, and another one with 3 arguments. In VBscript, I want to call the second constructor, but CreateObject only receives a classValue parameter, no possible arguments parameters. I guess the underlying implementation of CreateObject uses the system's CoCreateObject function, which according to this answer does not support arguments, but on the other hand there's QTP/UFT's DotNetFactory that

Call non-default constructor of COM class

。_饼干妹妹 提交于 2021-01-27 07:53:22
问题 I have a DLL (written in C#) containing a class with 2 Constructors; a default (no arguments) constructor, and another one with 3 arguments. In VBscript, I want to call the second constructor, but CreateObject only receives a classValue parameter, no possible arguments parameters. I guess the underlying implementation of CreateObject uses the system's CoCreateObject function, which according to this answer does not support arguments, but on the other hand there's QTP/UFT's DotNetFactory that

How can I share an interface between VB6 and C#?

二次信任 提交于 2021-01-27 07:10:49
问题 I would like to be able to code a class interface which I can implement in C# and VB6 classes so that these classes can be handled in the same way within VB6 code but I can't make this work. In VB6 I want to have come class VB6Class using the Implements key word to implement some interface ISharedInterface. In C# I want to have some other class C#Class which I can expose to COM as also implementing ISharedInterface. The goal is that VB6 code will then be able to operate on VB6Class and C

What is the correct type in c\c++ to store a COM's VT_DECIMAL?

荒凉一梦 提交于 2021-01-27 06:45:38
问题 I'm trying to write a wrapper to ADO. A DECIMAL is one type a COM VARIANT can be, when the VARIANT type is VT_DECIMAL . I'm trying to put it in c native data type, and keep the variable value. it seem that the correct type is long double, but I get "no suitable conversion error". For example: _variant_t v; ... if(v.vt == VT_DECIMAL) { double d = (double)v; //this works but I'm afraid can be loss of data... long double ld1 = (long double)v; //error: more then one conversion from variant to

What is the correct type in c\c++ to store a COM's VT_DECIMAL?

放肆的年华 提交于 2021-01-27 06:44:25
问题 I'm trying to write a wrapper to ADO. A DECIMAL is one type a COM VARIANT can be, when the VARIANT type is VT_DECIMAL . I'm trying to put it in c native data type, and keep the variable value. it seem that the correct type is long double, but I get "no suitable conversion error". For example: _variant_t v; ... if(v.vt == VT_DECIMAL) { double d = (double)v; //this works but I'm afraid can be loss of data... long double ld1 = (long double)v; //error: more then one conversion from variant to

How to use tlb files in a native C++ project

假如想象 提交于 2021-01-27 05:59:36
问题 I have a tlb files that contains some function declaration that I need to use. If I use #import "type_library.tlb" I can correclty reference the function from my code: tlb_namespace::required_function(); But when I compile the project the linker says that tlb_namespace::required_function is an unresolved external symbol. How can I succesfully build this kind of project? EDIT : I have used the same type library in a Dummy VBA access project. I have added the reference to the type library and I