calling DLL file by using vb.net

alvinblim

Well-known member
Joined
Jan 7, 2006
Messages
46
Location
malaysia
Programming Experience
3-5
hi,
i have some problem to calling the dll file. my dll file name is (dll.dll) my lib file name is (dll.lib). i need to call the dll function into my program.
Thank you

best regards,
alvin
 
Firstly i would say that naming a .Dll, Dll is not very good practice. However, you just need to add a reference to it in your project. Click 'AddReference' navigate to where the DLL is located and select it.
 
Help me please

Firstly i would say that naming a .Dll, Dll is not very good practice. However, you just need to add a reference to it in your project. Click 'AddReference' navigate to where the DLL is located and select it.

my dll file is created by my project partner. now i need to call their dll file come into my program.
this is the my project partner dll file coding:
// dll.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "dos.h"
#include "conio.h"

#pragma intrinsic (_outp)

////////////////////////////////////////////////////////
extern "C" __declspec(dllexport)void wp(int port, int pin);
extern "C" __declspec(dllexport)void rp();
////////////////////////////////////////////////////////

BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}

///////////////////////////////////////////////////////////

void wp(int port, int pin)
{
_outp(port, pin);
}
void rp(void)
{
_outp(0x378, 0);
}

he create the filename as dll.dll. i need to call the wp and rp function come
into my program. please help me. thank you very much
 
Also, if you mean that you want to access an unmanged library then it's a good idea to say so from the word go. Please provide all relevant information in your first post so people don't waste their time providing irrelevant replies.
 
Also, if you mean that you want to access an unmanged library then it's a good idea to say so from the word go. Please provide all relevant information in your first post so people don't waste their time providing irrelevant replies.


What is manage librabry and unmanaged library? inside (parallel.dll) file got 2 function that is wp and rp

// dll.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "dos.h"
#include "conio.h"

#pragma intrinsic (_outp)

////////////////////////////////////////////////////////
extern "C" __declspec(dllexport)void wp(int port, int pin);
extern "C" __declspec(dllexport)void rp();
////////////////////////////////////////////////////////

BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}

///////////////////////////////////////////////////////////

void wp(int port, int pin)
{
_outp(port, pin);
}
void rp(void)
{
_outp(0x378, 0);
}


inside my vb.net form.
my coding is

Private Declare Sub wp _
Lib "C:\Documents and Settings\limbh\Desktop\WindowsApplication7\parallel.dll" ( _
ByVal a As Integer, _
ByVal b As Integer _
)


Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
wp(888, 255)
End Sub
 
Private Declare Sub wp _
Lib "C:\Documents and Settings\limbh\Desktop\WindowsApplication7\paralle l.dll" ( _
ByVal a As Integer, _
ByVal b As Integer _
)


Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
wp(888, 255)
End Sub

i already try this code at my pc. it will pop up the error message like the following message:
"An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred in WindowsApplication7.exe
Additional information: External component has thrown an exception."

but i try run the same code in other pc, it will run successful. i cant find what is the error?
 
"Managed" means .NET, "unmanaged" means not .NET. The error is telling you that an exception was thrown in the external method. That would suggest to me that those parameters are not valid on the system that threw the exception.
 
my code is already can run in other pc. but cant run at my pc. i already cheak my pc parallel port is fine. but still have same error appear. if my parameter wrong, other pc should have same error with me. i am using windows xp pro sp2. How can i handle this problem? thank you.
 
Back
Top