Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problems using dllimport

Status
Not open for further replies.

diggityduncs

Programmer
Mar 5, 2002
6
US
Hello,

I'm tring to use a win32/api dll in c#

The vendor I received the dll from doesn't know anything about .net

I received two files
ACGAPI.DLL +
ACGAPI.LIB

and some example source code

Declaration:

Visual C/C++

extern "C" __declspec(dllimport) int __stdcall V5_CalculateActivationCode(LPSTR lpSiteCode, LPSTR lpProgramID, DWORD CustomFeatures, LPSTR lpActivationCode, LPSTR lpRemovalCode)

Visual basic:

Declare Function V5_CalculateInitCode Lib "ACGAPI.DLL" Alias "_V5_CalculateInitCode@20" (ByVal SiteCode As String, ByVal ProgramID As String, ByVal CustomFeatures As Long, ByVal ActivationCode As String, ByVal RemovalCode As String) As Long

Parameters:

(in)

LPSTR lpSiteCode - Pointer to Site code string (8 characters long)

LPSTR lpProgramID - Pointer to ProgramID (24 characters long)

DWORD CustomFeatures - Status of custom features (set to 0 if custom features are not required)

(out)
LPSTR lpActivationCode - Pointer to buffer for activation code (should be at least 36 character long)

LPSTR lpRemovalCode - Pointer to buffer for removal code (should be at least 9 character long)



This is code I came up with

using System.Runtime.InteropServices;

[DllImport("acgapi.dll")]
private static extern long V5_CalculateActivationCode(string SiteCode,string ProgramID,long CustomFeatures,string ActivationCode,string RemovalCode);

I get the following error when I run the code

Unable to find an entry point named V5_CalculateActivationCode in DLL acgapi.dll


I believe it may something to do with the .lib file. In the old visual studio you could add the .lib file in the project settings


but I'm not sure where you do this VS.net


Any help here would greatly be appreciated,
Thanks,
Paul
 
If you have VS.NET 2003, you can write a managed C++ wrapper around the vendor's code (since they were nice enough to give you the .lib and function prototype), and make it into an assembly. You can then call it from your C# code by referencing the assembly like any other .NET assembly. All through the magic of the Common Language Runtime!

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top