Tech Support > Microsoft Windows > Development Resources > dll need help
dll need help
Posted by kalvin on January 8th, 2004


I am encounter some problem in linking dll and vb. I first create a
dll file and and compile success in vc++ but when i link with vb it
prompt me some error message.Can anybody please help me?The below is
my source code.Thanks you

/*this is a dll source code*/
void _stdcall success(long int c)
{
int X,Y;
for(X=0;X<20;X++)
for(Y=0;X<20;X++)
SetPixel( (HDC)c, X, Y, 0) ;

}

vb declaration
Private Declare Function success Lib "s.dll" (ByVal a As Long)

Dim a As Long
a = CLng(Form1.Picture1.hDC)

success (a)

Posted by Tim Robinson on January 8th, 2004


"kalvin" <chanfoong2002@yahoo.com> wrote in message
news:ffc96d80.0401080309.1c75cb97@posting.google.c om...
What error message do you see?


Looks like you've got X and Y mixed up. This code should probably be:

for (X = 0; X < 20; X++)
for (Y = 0; Y < 20; Y++)
SetPixel((HDC) c, X, Y, 0);

--
Tim Robinson (MVP, Windows SDK)
http://www.themobius.co.uk/



Posted by Craig Kelly on January 8th, 2004


"kalvin" <chanfoong2002@yahoo.com> wrote:
Your VB Declare is wrong: you've defined success as a Function returning a
Variant. You should change it to:

Private Declare Sub success Lib "s.dll" (ByVal a As Long)

If the error you're getting is that the DLL can't be located or the function
can't be located, make sure the DLL is accessible from your VB program (e.g.
the same directory) and that "success" is actually the exported function
name (not _success or success@4 or
success@bunch_of_compiler_and_linker_stuff).

Craig