|
| Including code written in C# |
| Débuté par Simon Phillips, 27 fév. 2026 13:10 - Aucune réponse |
| |
| | | |
|
| |
| 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 |
| |
| |
| | | |
|
| | | | |
| | |
|