PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Including code written in C#
Including code written in C#
Débuté par Simon Phillips, 27 fév. 2026 13:10 - 2 réponses
Posté le 27 février 2026 - 13:10
Hi all.

Can anyone help me with including C# code in a Windev app. I don't speak C#, as never needed to since everything is included in WinDev, but as the SendKey function does not allow WIN key (i.e. WIN+H), then I need to try using some C code I have found on-line.

What I have done is created a global procedure, and changed the code type to C#
I then added the code:-

public static void SendWINH()
{
INPUT inputs[4] = {};
ZeroMemory(inputs, sizeof(inputs));

inputs[0].type = INPUT_KEYBOARD;
inputs[0].ki.wVk = VK_LWIN;

inputs[1].type = INPUT_KEYBOARD;
inputs[1].ki.wVk = 'H';

inputs[2].type = INPUT_KEYBOARD;
inputs[2].ki.wVk = 'H';
inputs[2].ki.dwFlags = KEYEVENTF_KEYUP;

inputs[3].type = INPUT_KEYBOARD;
inputs[3].ki.wVk = VK_LWIN;
inputs[3].ki.dwFlags = KEYEVENTF_KEYUP;

UINT uSent = SendInput(ARRAYSIZE(inputs), inputs, sizeof(INPUT));
}

Then in the Window procedure, I call this with:

SendWinH()

Compiles and runs ok, but when I call the procedure I get the error:

<SET_GlobalProcedures> object unknown in <C:\My Projects\TestC\Exe\TestC.dll> assembly.
Check whether version of <C:\My Projects\TestC\Exe\TestC.dll> assembly used in execution matches version used to compile the project.
Unable to create <WL.SET_GlobalProcedures> object (<C:\My Projects\TestC\Exe\TestC.dll> assembly)
Unable to open the <C:\My Projects\TestC\Exe\TestC.dll> assembly
Error returned by .NET Framework:
Could not load file or assembly 'file:///C:\My Projects\TestC\Exe\TestC.dll' or one of its dependencies. The system cannot find the file specified.
Unable to open the <TestC> assembly

Call stack:
Click BTN_CallCCode (WIN_Main.BTN_CallCCode), line 2

Date: 27/02/2026 12:06:43
Project: TestC

Additional information:
Error code: 200007
Module: wd310net464.dll (01A311075 - 31.0.198.1)

Debugging information:
System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\My Projects\TestC\Exe\TestC.dll' or one of its dependencies. The system cannot find the file specified.
File name: 'file:///C:\My Projects\TestC\Exe\TestC.dll'
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at CDotNetLoader.__pclLoadAssembly(CDotNetLoader* , Char* fileName, CXError* pclErreur)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

EIT_TYPE_WDFILE : <2>
EIT_IDCODE : <18>
----- Sub-error #1 -----

Unable to open the <TestC> assembly
Error code: 200003
Module: wd310net464.dll (01A311075 - 31.0.198.1)


----- Sub-error #2 -----

Unable to open the <C:\My Projects\TestC\Exe\TestC.dll> assembly
Error returned by .NET Framework:
Could not load file or assembly 'file:///C:\My Projects\TestC\Exe\TestC.dll' or one of its dependencies. The system cannot find the file specified.
Error code: 200007
Module: wd310net464.dll (01A311075 - 31.0.198.1)

Debugging information:
System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\My Projects\TestC\Exe\TestC.dll' or one of its dependencies. The system cannot find the file specified.
File name: 'file:///C:\My Projects\TestC\Exe\TestC.dll'
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at CDotNetLoader.__pclLoadAssemblyWithFullPath(CDotNetLoader* , Char* fileName, CXError* pclErreur)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].



----- Sub-error #3 -----

Unable to open the <TestC> assembly
Error code: 200003
Module: wd310net464.dll (01A311075 - 31.0.198.1)


Obviously I am missing something basic, but cannot find anything on the help and this is my first C# venture.

Any ideas would be most appreciated.

Thanks
Simon Phillips
Membre enregistré
23 messages
Posté le 28 février 2026 - 02:41
Hi Simon,

Save yourself a lot of work and just use the WIndows API.

There's a couple of ways of doing it but an easy way is as follows:

// To open Windows Explorer

// Win down
CallDLL32("user32", "keybd_event", 0x5B, 0, 0, 0)
// 'E down
CallDLL32("user32", "keybd_event", Asc("E"), 0, 0, 0)
// 'E' up
CallDLL32("user32", "keybd_event", Asc("E"), 0, 0x0002, 0)
// Win up
CallDLL32("user32", "keybd_event", 0x5B, 0, 0x0002, 0)

Put this in a button to test it.

Best Regards,
Geoff
Message modifié, 28 février 2026 - 03:06
Membre enregistré
96 messages
Posté le 02 mars 2026 - 19:14
<SET_GlobalProcedures> object unknown in <C:\My Projects\TestC\Exe\TestC.dll> assembly.

Hi Simon

If you get an error in a dll that has the same name as you application, it means that pcsoft and the MS Compiler could not agree on compiling the interface dll for your .net code to be called by WX.

This is normally a problem in your c# code, either an include or something else WX does not pick up.

I got around this by compiling my code and running my code in VS or VSCode before including it in the WX solution.

Regards

Ben

--
Ben Dell
Riebens Computers Pty Ltd
Southern Africa PcSoft Distributor
www.windevsa.co.za
PcSoft Sales, Support and Training