New Member

Group: Members
Posts: 5
Member No.: 1319
Joined: 9-June 05

|
Hi guys,
Thanks a lot for your response. I was able to return a string by using SysAllocString to be used as:
| CODE | dim x as string
x=asmReturnAString() |
This works fine, as for passing by reference is concerned, I was only able to copy from parameter 1 to parameter2 as follows in MASM32:
| CODE | asmStringByRef proc lpString:LPCTSTR,lpRetByRef:LPCTSTR
; Proc works if lpString is declared as LPSTR/LPCTSTR/DWORD and ; lpRetByRef declared as ptr dword/dword/LPSTR,even LPCTSTR
mov esi, dword ptr [lpString] mov edi, dword ptr [lpRetByRef]
@label:
mov al, [esi] inc esi mov byte ptr [edi],al inc edi cmp al,0 jne @label Ret
asmStringByRef EndP |
...in Visual Basic:
| CODE | Private Declare Sub asmStringByRef Lib "C:\asmICLogix.dll" (sVal As String, sRef As String) ' As Long
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' asmStringByRef test results ' p1 -> p2: byRef->ByRef ' ' p1 : DWORD/LPSTR/LPCTSTR ' p2: ptr dword/dword/LPSTR,even LPCTSTR ' ' Quotes accepted on p1 for asmStringByRef ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Private Sub Test ()
Dim s As String, z As String
z = "ICLrpt1.tmp" Call asmStringByRef(z, s) MsgBox s
End Sub |
My asmGetNewTempFile proc does not return the string in parameter strNewFileName:
| CODE | asmGetNewTempFile proc strPrefix :DWORD, strNewFileName:BYTE
; strPrefix was originally LPCTSTR, works even if DWORD ; param1:DWORD, param2:PTR DWORD works, param1:LPSTR,param2:PTR DWORD works
;; pass LPCTSTR directly local strFullPath[256]:byte invoke GetTempPath, 256, addr strFullPath; contains path only invoke lstrcat, addr strFullPath,strPrefix
invoke CreateFile, addr strFullPath, GENERIC_READ or GENERIC_WRITE, FILE_SHARE_READ or FILE_SHARE_WRITE,\ NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL or FILE_FLAG_DELETE_ON_CLOSE, NULL
lea eax,strFullPath mov edx,0
@label:
mov al,byte ptr [strFullPath+edx] mov byte ptr [strNewFileName+edx],al inc edx cmp al,0 jne @label ret
asmGetNewTempFile EndP |
I would like to know what changes are needed to support byVal in vb and how to make strNewFileName return a string by reference. I am still learning, so your help will be much appreciated, even on the other procs contained in the project. Kindly test the dll for me, I hope it is not heavily bugged. Thanks a lot for your help, keep the good job going. Sachin.
Attached File ( Number of downloads: 21 )
Login or Register to download
|