Using C# function from dll in PowerShell

I’m relatively new to PoSh, so this is a bit advanced for me. I’d like to use a C# function in a DLL.

C# Function:

int EloGetDiagnosticsData(PSCREEN_PROPERTIES pData, UINT nScrNo) 

The PSCREEN_PROPERTIES data type is defined as:

typedef struct _SCREEN_PROPERTIES { int iWindowsMonNo ; ULONG Type; char Port[256]; char SerialNumber[18]; DWORD HardwareHandshaking ; CONTRL_STAT ctrl_status; LONG BaudRate; char crevminor; char crevmajor; char trevminor; char trevmajor; char diagcodes[8]; char id[8]; char cnt_id[8]; char driver_id[32]; }SCREEN_PROPERTIES, *LPSCREEN_PROPERTIES; 

I know I can use DLLImport to accomplish it, and some of the code probably looks like this:

$GetEloScreenInfo = @' [DllImport("EloPubIf.dll", EntryPoint = "EloGetDiagnosticsData")] public static extern int EloGetDiagnosticsData(SCREEN_PROPERTIES data, System.UInt32 scrnum); '@ 

How would I go about defining the structure SCREEN_PROPERTIES in PowerShell, then calling the function?

submitted by /u/Marc05
[link] [comments]

Leave a Reply