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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DLL declaration

Status
Not open for further replies.

keenanbr

Programmer
Oct 3, 2001
469
0
0
IE
What is the C# equivalent


VB6

Declare Function EHNDQ_Create Lib "EhnDQw32.DLL" (ByVal lHandle As Integer, ByVal lpszQueueName As String, ByVal lpszQueueLocation As String, ByVal lMaxLength As Long, ByVal nSequence As Integer, ByVal nForce As Integer, ByVal nAuthority As Integer, ByVal nSenderid As Integer, ByVal lpszText As String) As Integer


C#

[DllImport("EhnDQw32.dll")]
public static extern int EHNDQ_Create(int Pid, String QueueName, String QueueLocation, long maxLength, int sequence, int force, int authority, int senderid, string txt);

in C# I get 'AfxOleInit failed'


Regrads,

 
AfxOleInit should be a clue that the DLL you're trying to call is a COM DLL, and not a Win32 dll.

The style of import you posted is for Win32 DLLs. Go to the "Add Reference.." dialog and choose your COM DLL from there.

Chip H.



____________________________________________________________________
www.chipholland.com
 
If I do that it tells me

a reference to .....\ehndqw32.dll could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.
 
This Vb.Net program works fine


Option Strict Off
Option Explicit On
Module Module1

Declare Function EHNDQ_Create Lib "EhnDQw32.DLL" (ByVal lHandle As Short, ByVal lpszQueueName As String, ByVal lpszQueueLocation As String, ByVal lMaxLength As Integer, ByVal nSequence As Short, ByVal nForce As Short, ByVal nAuthority As Short, ByVal nSenderid As Short, ByVal lpszText As String) As Short

Public Sub Main()
Dim gs_TempLibraryName As String
Dim gs_TempQueueName As String
Dim gs_TempSystemName As String
Dim ll_MaxLength As Integer
Dim li_Sequence As Short
Dim li_Force As Short
Dim li_Authority As Short
Dim li_Senderid As Short
Dim ls_Text As String
Dim qName As String
Dim Pid As Short
Dim nretvalue As Short

gs_TempLibraryName = "QGPL"
gs_TempQueueName = "DQAACT0012"
gs_TempSystemName = "LIFEDEV"
ll_MaxLength = 2050
li_Sequence = 1
li_Force = 0
li_Authority = 3
li_Senderid = 0
Pid = 567

ls_Text = "Temp Queue started on " & VB6.Format(Now, "dd/mm/yyyy") & " at " & VB6.Format(Now, "hh:mm:ss")

qName = gs_TempLibraryName & "/" & gs_TempQueueName

nretvalue = EHNDQ_Create(Pid, qName, gs_TempSystemName, ll_MaxLength, li_Sequence, li_Force, li_Authority, li_Senderid, ls_Text)
End Sub
End Module


but the equivelant c# doesn't


using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;


namespace ConsoleApplication10
{
class Program
{
[DllImport ("EhnDQw32.dll")]
public static extern short EHNDQ_Create(short Pid, String QueueName, String QueueLocation, int maxLength, short seq, short force, short authority, short senderid, String txt);
static void Main(string[] args)
{
String gs_TempLibraryName;
String gs_TempQueueName;
String gs_TempSystemName;
int ll_MaxLength;
short li_Sequence;
short li_Force;
short li_Authority;
short li_Senderid;
string ls_Text;
string qName;
short Pid;
short nretvalue;

gs_TempLibraryName = "QGPL";
gs_TempQueueName = "DQAACT0012";
gs_TempSystemName = "LIFEDEV";
ll_MaxLength = 2050;
li_Sequence = 1;
li_Force = 0;
li_Authority = 3;
li_Senderid = 0;
Pid = 567;

ls_Text = "Temp Queue started on 24/04/2009 at 11:26:10";

qName = gs_TempLibraryName + "/" + gs_TempQueueName;

nretvalue = EHNDQ_Create(Pid, qName, gs_TempSystemName, ll_MaxLength, li_Sequence, li_Force, li_Authority, li_Senderid, ls_Text);

}
}
}
 
But your working version of vb.net does not seem to have alias, hence, maybe, afterall, it is optional.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top