dllimport

web service works in asp.net but not iis

I have built a web service that uses DLLImport to access unmanaged code. The service works just fine running in ASP.NET server but the application is generating an error once I run it from IIS. I have checked permissions, moved ddl to system32, etc. I am not sure what else to do, the service needs to run in IIS. What should I do? ...

How to P/Invoke when pointers are involved

In an attempt to learn to use PInvoke in C#, I'm a little unsure how to handle various cases with pointers involving simple value types. I'm importing the following two functions from an unmanaged DLL: public int USB4_Initialize(short* device); public int USB4_GetCount(short device, short encoder, unsigned long* value); The first fun...

C# Newbie: How do I fix this code to do a DNS lookup?

This is my first time using C#, so I'm very much out of my element. But I have faith that the wonderful people here at Stack Overflow can help me out! I've come up with the following code (below) based on some other pieces of code I found floating around on the internet. What I am trying to do is to look up all the "text" DNS records (TX...

Dllimport can't import an old Borland dll

I have a lot of legacy code which I currently compile using an antiquated install of Borland C++ 3.0. There's a rules engine in this code that I'd like to extract and use in a C# .NET application. The thing is, if I extract the rules engine into it's own DLL, I want to be able to call this DLL from both the existing legacy code which I...

What is wrong with my DLLImport of LogonUser with String Marshaling? [C#]

For some odd reason, when I marshal the LogonUser DLLImport parameters I am no longer able to login succesfully when using the INTERACTIVE logon type, it works for NETWORK logon type. This is my code: [DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)] public static extern bool LogonUser ( ...

free memory not clears the memory block

Hi, I am using DllImport to call method in c wrapper library from my own .net class. This method in c dll creates a string variable and returns the pointer of the string. Something like this; _declspec(dllexport) int ReturnString() { char* retval = (char *) malloc(125); strcat(retval, "SOMETEXT"); strcat(retval, "SOMETEXT MORE"); ...

How to set up a C++ function so that it can be used by p/invoke?

Hopefully this is a brainlessly easy question, but it shows my lack of expertise with C++. I'm a C# programmer, and I've done extensive work with P/Invoke in the past with other people's C++/C dlls. However, this time I've decided to write a wrapper C++ dll (unmanaged) myself, and am then calling my wrapper dll from C#. The problem I ...

Converting a Windows Dll to .lib for C++ Visual Studio 2008

I know there is a tool called Dll to lib but the developer is asking $1000. I only need to convert one library, once, so its not easy to justify that price. I tried IMPLIB32.EXE, but I just get empty .lib files. How can I accomplish this? Perhaps I can write a simple conversion app? Added1: The Dll's are typically stdcall not cdecl an...

C#-fortran (lahey visual 7.2) communications

I am new to C#; I need to get my fortran dll to communicate with my C# program. I am able to pass variables from my program into C# using set (subroutines) and get (functions) (i.e., ! fortran function getSwitch() result(value) use module implicit none dll_export :: getSwitch logical :: value value = getkSwitch() end fun...

Is there any native DLL export functions viewer?

Is there any free native Windows DLL export functions viewer, which shows the function name, and a list of their parameters? Thanks. ...

Is it possible to restart a PC using "pure" .NET and *without* using p/invoke?

Is it possible, without employing pinvoke, to restart a PC using .NET? I kind of just repeated the title, but I'm not too sure how to elaborate much further! Edit: I should have mentioned that don't want to use "shutdown -r" as a solution. I was really after a pure .NET way, something like: Environment.ShutDown(); In other words, s...

Under what conditions will you get unresolved external symbol for __declspec(dllimport)?

I am converting an application to use .dlls and I'm riddled with linker errors stating unersolved external symbol"__declspec(dllimport) public: void __thiscall Rail::SetNextrail(class Rail *)" There is more gibberish at the end of this error message. Why should this happen and how do you fix it? __declspec(dllimport) is be...

CPU Architecture Independent P/Invoke: Can the DllName or path be "dynamic"?

Is there a way to have the particular DLL referenced by a P/Invoke (DllImport) signature depend on the CPU architecture? I'm working on an application that loads a large number of method signatures from a native dll from a third party vendor, in this case the user-space interface DLL to a piece of hardware. That vendor has now started ...

Can't use DLL (written in C++) in Delphi: The procedure entry point could not be located

I've compiled a DLL in Visual Studio (the source code is in C++, which I barely understand). Here's a piece of Scraper.h: struct SWin { char title[512]; HWND hwnd; }; SCRAPER_API bool ScraperGetWinList(SWin winList[100]); Now I'm trying to use the above function in my Delphi application: type tWin = record title: String;...

Delphi: Access violation after calling function from external DLL (C++)

There's a function, written in C++ and compiled as DLL, which I want to use in my Delphi application. Scraper.cpp: SCRAPER_API bool ScraperGetWinList(SWin winList[100]) { iCurrWin=0; memset(winList,0,100 * sizeof(SWin)); return EnumWindows(EnumProcTopLevelWindowList, (LPARAM) winList); } Scraper.h: #ifdef SCRAPER_EXPORTS...

Is there a more painless way to call Win32 from C#?

Every few months I find myself needing to call Win32 from C#. Though I've done it a dozen times, I've usually forgotten the exact machinations, so I poke around the web or old code and figure out what DllImport statements I need, etc. Am I alone? Is there a sanctioned "Win32" class that has the requisite declarations for the entire Win...

DllImport a c++ DLL in to a C# app, BYTE * p

Hello I have a exported function in a c++ DLL // C++ DLL (Blarggg.dll) extern "C" { USHORT ReadProperty( BYTE * messsage, USHORT length, BYTE * invokeID ) { if( invokeID != NULL ) { * invokeID = 10 ; } return 0; } } That I would like to make it available to my C# application /...

Catching WM_GETMINMAXINFO from notepad.exe doesn't work

Hello! I want to catch all WM_GETMINMAXINFO messages which are sent to the "nodepad.exe" application. My base app is written in C#, the DLL with the windows hook is written in C. Let me show you the hook inside the C DLL: file: dll.h #ifndef _DLL_H_ #define _DLL_H_ #include <windows.h> #if BUILDING_DLL # define DLLIMPORT __declspec...

Trying to create a Math Input Panel in C#

How do I create a Math Input Panel in C#? I have tried to put it into a dll and call it but it just closes right away. #include <stdafx.h> #include <atlbase.h> #include "micaut.h" #include "micaut_i.c" extern "C" __declspec(dllexport) int run() { CComPtr<IMathInputControl> g_spMIC; // Math Input Control HRESULT hr = CoInitializ...

C# call to unmanaged C++ returning string of squares symbols

I have some C# code calling into an unmanaged C++ DLL. The method I am calling is intended to accept a string as a ref. To handle this I pass in a StringBuilder, otherwise there is a StackOverflowException. This is working fine, but on some calls the string that comes back from the unmanaged code is a jumbled string like this: øŸE˜.,Ê...