dllimport

Error: function definition is marked dllimport

佐手、 提交于 2019-12-06 11:28:22
I'm attempting to get a toy program running with AVT's VIMBA SDK. At the moment, it is going well save for one caveat. When I attempt to compile, I get a series of errors (14 of them) that all are marked same thing: function *insert call here* definition is marked dllimport The file itself is below- the curious thing is that in in this file, only ~IFeatureObserver(), IFeatureObserver(), and IFeatureObserver( const IFeatureObserver& ) are triggering the error; FeatureChanged() does not error out during a compile. #ifndef AVT_VMBAPI_IFEATUREOBSERVER_H #define AVT_VMBAPI_IFEATUREOBSERVER_H

Passing String from Native C++ DLL to C# App

匆匆过客 提交于 2019-12-06 09:45:57
I have written a DLL in C++. One of the functions writes to a character array. C++ Function EXPORT int xmain(int argc, char argv[], char argv2[]) { char pTypeName[4096]; ... //Other pTypeName ends up populated with "Portable Network Graphics" //This code verifies that pTypeName is populated with what I think it is: char szBuff[64]; sprintf(szBuff, pTypeName, 0); MessageBoxA(NULL, szBuff, szBuff, MB_OK); //The caption and title are "Portable Network Graphics" ... //Here, I attempt to copy the value in pTypeName to parameter 3. sprintf(argv2, szBuff, 0); return ret; } C# Import //I believe I

Mouse move in game window by outer C# code

泄露秘密 提交于 2019-12-06 08:54:11
I am playing a game, every time I need to move mouse and click into the game's screen to earn game point, so I am trying to write code by c# to click and move mouse in game's screen automatically .. I got some help, so mouse click problems solved, but I am unable to move mouse in game's screen.. Can you please advice me what should I do ?? Should I use "SetWindowsHookEx" or other methods to move mouse in game window ?? Please advice me what should I do.. "Click" code below which I got, it's working fine : public class ClickGameScreen { [DllImport("user32.dll")] static extern bool

Passing method pointer from C# to Delphi DLL

为君一笑 提交于 2019-12-06 08:22:31
问题 I've had some problems passing string as PChar to Delphi built DLL, and resolved it thanks to Jens Mühlenhoff. Now I have another issue - I've made successful callback of c# method when passed to DLL if the Delphi declaration is a regular type procedure, but if Delphi declaration is a method type procedure I get "Attempted to read or write protected memory" error. I tried searching... Here is Delphi declaration TCallBack = procedure ( s : String) of object;stdcall; Here is C# code [DllImport(

PInvoke code usage in C#

守給你的承諾、 提交于 2019-12-06 07:46:06
I have the following C# code that uses DLLImport. using System; namespace LvFpga { class RegTest { [DllImport("kernel32")] public extern static int LoadLibrary(string lpLibFileName); [DllImport("kernel32")] public extern static bool FreeLibrary(int hLibModule); public static bool IsDllRegistered(string DllName) { int libId = LoadLibrary(DllName); if (libId>0) FreeLibrary(libId); return (libId>0); } public static void Main(string[] args) { Console.WriteLn(IsDllRegistered("msdia100.dll")); } } } When I simply run csc CSCODE.cs I got the errors. regtest.cs(7,6): error CS0246: The type or

P/Invoke with Shell32, bypass Interop.Shell32.dll generation

醉酒当歌 提交于 2019-12-06 07:19:55
问题 So I'm using the following code to dump every extended file attribute to the debug console... ShellClass shellClass = new ShellClass(); Folder dir = shellClass.NameSpace(Path.GetDirectoryName(sFilePath)); FolderItem item = dir.ParseName(Path.GetFileName(sFilePath)); for (int i = 0; i < 267; i++) { System.Debug.WriteLine(dir.GetDetailsOf(item, i)); } As Shell32 is a non-managed library, I can't embed the DLL resource in the program directly, and it has to generate an interop helper DLL. Anyone

C# formatting external Dll function parameters

纵饮孤独 提交于 2019-12-06 06:54:53
问题 I have yet to find a good reference on this topic. For this example we will take some C++ code that I'm trying to port over to C#. In C++ land we have the following prototype for an external library function: extern "C" DWORD EXPORT FILES_GetMemoryMapping( PSTR pPathFile, PWORD Size, PSTR MapName, PWORD PacketSize, PMAPPING pMapping, PBYTE PagesPerSector); and in it is used like such: FILES_GetMemoryMapping((LPSTR)(LPCTSTR)MapFile, &Size, (LPSTR)MapName, &PacketSize, pMapping, &PagePerSector)

Using dllimport with Visual C++

跟風遠走 提交于 2019-12-06 06:23:23
I've not done any windows programming for a few years now and I'm a bit rusty on how to use dllimport. I have something along the lines of: extern "C" { __declspec(dllimport) int myFunct(); } int main() { cout<<myFunct(); } I get 2 unresolved externals linker errors and a warning that /DELAYLOAD:myLib.dll was ignored because no imports from it were found. What am I missing here? I thought that I can add the DLL to the delay load path, and the linker will figure to use it for the dll import?? This is a 3rd party DLL which comes without .h or .lib file. If you want to link DLL at runtime, you

Using Unicode strings in DllImport with a DLL written in Rust

扶醉桌前 提交于 2019-12-06 04:37:54
I am trying to call a DLL written in Rust from a C# program. The DLL has two simple functions that take stings (in different manner) and prints to the console. Rust DLL code #![crate_type = "lib"] extern crate libc; use libc::{c_char}; use std::ffi::CStr; #[no_mangle] pub extern fn printc(s: *const c_char){ let c_str : &CStr = unsafe { assert!(!s.is_null()); CStr::from_ptr(s) }; println!("{:?}", c_str.to_bytes().len()); //prints "1" if unicode let r_str = std::str::from_utf8(c_str.to_bytes()).unwrap(); println!("{:?}", r_str); } #[no_mangle] pub extern fn print2(string: String) { println!("{:?

Is there any way to debug what is going on after my .NET code calls a function in an unmanaged dll via dllimport?

删除回忆录丶 提交于 2019-12-06 04:30:47
问题 Is there any way to debug what is going on after my .NET code calls a function in an unmanaged dll via dllimport? I expose a dll function inside an unmanaged via dllimport. When I call a function as I step through the code, something happens and it never returns. Is there anything I can do, maybe with debug view or anything to get any information? Or am I SOL? 回答1: Well, for starters, make sure you have native code debugging enabled in the Debug tab of your project's properties. If you have