this is a simple problem, but i dont know whats wrong.!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! GetDllPathQuser32 doesnt return any string in vb.
i debuged it and it looks ok.

im using the following code for vb
Public Declare Function GetDllPathQuser32 Lib "QUSER32.dll" () As String
and the asm code


.data
Qdllname db "\QUSER32.DLL",0
.Data?
dirbufferx1 db 256 dup(?)
.code
StringLen Proc ptrSTRING1:DWORD
pushf
push esi
push ebx
mov esi,ptrSTRING1
xor ebx,ebx
xor eax,eax
@@:
mov bl,BYTE PTR [esi+eax]
inc eax
cmp bl,0
jne @B
dec eax
pop ebx
pop esi
popf
ret
StringLen endp
;=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|=-|
StrCmb Proc PTRdest long,PTRsrc long;first MUST be a buffer with enuf space, second can be
; any thing, both must be null termanated
pushad
pushf
mov ecx,PTRdest;dest cmb
mov ebx,PTRsrc;src
invoke StringLen,ecx
add ecx,eax
Invoke StringLen,ebx
cmp eax,0
je @1
mov edi,eax
xor eax,eax
xor edx,edx
mov dl,BYTE PTR [ebx]
mov BYTE PTR [ecx],dl
cmp eax,edi
je @NULLO
@@:
inc eax
mov dl,BYTE PTR [ebx+eax]
mov BYTE PTR [ecx+eax],dl
cmp eax,edi
jne @B
@NULLO:
inc eax
mov BYTE PTR [ebx+eax],0
@1:
popf
popad
ret
StrCmb EndP

GetDllPathQuser32 Proc
sav;pushad pushf etc
Invoke GetCurrentDirectory,255,Addr dirbufferx1
Invoke StrCmb,Addr dirbufferx1,Addr Qdllname
res ;popad
mov eax,Offset dirbufferx1
ret
GetDllPathQuser32 EndP
Posted on 2002-05-19 22:18:54 by Qages
To return a string to your VB app, you should allocate a fixed length buffer, pass it to the asm dll, let the asm dll fill it, then if necessary in the VB app you can use CopyMemory to transfer the contents of the buffer into a proper VB string. To allocate the buffer, use a byte array.

You could also try passing a string ByVal to the dll, for it to store info in, but this is not recommended for two reasons:
- you could easily write past the end of the string, causing a GPF
- the string is stored in temporary heap area, you have to be very careful when writing to the string because VB is always doing crazy sh*t with the heap area

Another alternative is to return a VB Long from the dll, which of course would be a pointer to the string, you can then use CopyMemory to copy the string back to a VB string.
Posted on 2002-05-20 00:52:56 by sluggy
Qages,

========================================
Public Declare Function GetDllPathQuser32 Lib "QUSER32.dll" () As String
========================================

Just check out the documentation for your dialect of basic to see if it has the ALIAS keyword. It is usually used to make sure the exported name is case correct.

If it does, you set the ALIAS as the case sensitive name to ensure that the correct export is found, "Function" is NOT the same as "FUNCTION" so you will need to be careful here.

Regards,

hutch@movsd.com
Posted on 2002-05-20 02:23:04 by hutch--
ill just have to use byval and
c = Space(255)
GetDllPathQuser32 c
Text3.Text = c
well thx, there should be an easer way,to just pass the pointer to the buffer like i first did... but oh well
Posted on 2002-05-20 17:12:47 by Qages
well thx, there should be an easer way,to just pass the pointer to the buffer like i first did... but oh well
If you had used a byte array as the buffer, you could have just passed the first element of the array ByRef, which is the same as passing a pointer to the array, but then you would have had to copy the buffer back into a string to use it.

What you have done is the technically correct way, and is the way used with most API calls when you expect a string back.

Blame COM and the VB runtime for the difficult way you have to do these things :)
Posted on 2002-05-20 19:52:26 by sluggy