Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run my third-party DLL file with PowerShell

I am not sure if this is possible or not with PowerShell.

But basically I have a Windows Forms program that configures a program called EO Server. The EO Server has an API, and I make a reference to EOServerAPI.dll to make the following code run.

using EOserverAPI; ... private void myButton_Click(object sender, EventArgs e) {     String MDSConnString="Data Source=MSI;Initial Catalog=EOMDS;Integrated Security=True;";      //Create the connection     IEOMDSAPI myEOMDSAPI = EOMDSAPI.Create(MDSConnString);      //Get JobID     Guid myMasterJobID = myEOMDSAPI.GetJobID("myJobRocks"); } 

Is it possible to interact with an API DLL file and make the same types of calls as you would in a Windows Forms application?

like image 865
MicroSumol Avatar asked Nov 01 '11 19:11

MicroSumol


People also ask

How do I register a DLL in PowerShell?

Another way to register the DLL files is by using a command-line interface like MS-DOS or PowerShell. First, we will open the command line interface from the Start Menu. In the following example, we will open the PowerShell. Now we will type the regsvr32 command like below.

How do I convert a DLL file to readable?

Microsoft Windows 7 and newer Registry Open the folder with the DLL file. Once you find the folder, hold the Shift key and right-click the folder to open the command prompt directly in that folder. Type "regsvr32 [DLL name]. dll" and press Enter.


1 Answers

Yes, you can:

Add-Type -Path $customDll $a = new-object custom.type 

You call a static method like so:

[custom.type]::method() 

Instead of Add-Type, you can also use reflection:

[Reflection.Assembly]::LoadFile($customDll) 

(Note that even the above is calling the Reflection library and the LoadFile static method.)

like image 90
manojlds Avatar answered Sep 18 '22 17:09

manojlds