Passing Data from Visual Basic to Progress using memptr

Jon100

New Member
Hi,

I am trying to transfer data from a visual basic application to a progress application. The data could be extensive so I don't want to use input output params etc. I have thought of loading the data into memory within the Visual basic app and passing the memory pointer to the progress app so progress can retrieve the data.

The Vb code below works fine and stores/retrieves the test data. I then pass the memptr as an integer to progress. Progress then does not return any data. I think it is because the memptr has been passed to progress as an integer. Is there a way of passing progress the actual memory pointer without any conversion?

Progress Version 9.1C25


Thanks in Advance



The vb code I am using is

Private Declare Sub CopyMemory Lib "kernel32" _
Alias "RtlMoveMemory" (Destination As Any, _
Source As Any, ByVal Length As Long)

Private Declare Sub CopyMemoryWrite Lib "kernel32" Alias _
"RtlMoveMemory" (ByVal Destination As Long, Source As Any, _
ByVal Length As Long)

Private Declare Sub CopyMemoryRead Lib "kernel32" Alias _
"RtlMoveMemory" (Destination As Any, ByVal Source As Long, _
ByVal Length As Long)

Private Declare Function GetProcessHeap Lib "kernel32" () As Long

Private Declare Function HeapAlloc Lib "kernel32" _
(ByVal hHeap As Long, ByVal dwFlags As Long, _
ByVal dwBytes As Long) As Long

Private Declare Function HeapFree Lib "kernel32" _
(ByVal hHeap As Long, ByVal dwFlags As Long, lpMem As Any) As Long

Public Function GetAlphaName(ByVal P_LETTER As String) As Long

Dim ptr As Long
Dim hHeap As Long
hHeap = GetProcessHeap()

ptr = HeapAlloc(hHeap, 0, 2)

If ptr <> 0 Then
Dim testtext As String

testtext = "TEST"

CopyMemoryWrite ptr, CStr(testtext), 2
testtext = ""

CopyMemoryRead testtext, ptr, 2

MsgBox "The Address of ptr is " & CStr(ptr) & vbCrLf & "and the value is " & testtext

GetAlphaName = ptr

End If


Progress code:

/* defined in definitions block */
Procedure RtlMoveMemory External "kernel32":
Def output param destination as char.
Def input param source as long.
Def input param length as long.
End procedure.

Define var P-ENTRY As integer No-undo.

Def var mymemptr as integer no-undo.
Def var mystring as char.

P-ENTRY = V-OBJSESSION:getAlphaName ( P-LETTER ).

Run RtlMoveMemory (output mystring, p-entry, 2).

message mystring.
 
It's a bit tricky though. But I think you need something like that.

Code:
Define var P-ENTRY As integer No-undo.
Def var mymemptr as MEMPTR no-undo.
Def var mystring as char. 
P-ENTRY = V-OBJSESSION:getAlphaName ( P-LETTER ).
/* Commented by KSV: Getting string using pointer in p-entry */
SET-POINTER-VALUE(mymemptr) = p-entry.
mystring = GET-STRING(mymemptr,1,2).
message mystring.

I can avoid using RtlMoveMemory because I can read the string using its pointer in 'p-entry'. I'm not sure about SET-POINTER-VALUE in 9.1C but it exists in 9.1D.

HTH
 
Thanks for the info about SET-POINTER-VALUE, it does exist in 9.1C. But unfortunatley the get-string returns random characters and not the word test. I have also tried it with the rtlmovememory call and that does not work either.

Have you any other suggestions?


Thanks

Jon.
 
Could you extend your snippet a bit because I have no idea what V-OBJSESSION is? How do you call VB code from PROGRESS?
 
Hi,

The code connects to lotus notes comm via a Vb DLL which we have written ourselves in house.

Progress Connection code:-

Def var V-OBJSESSION as com-handle no-undo.

Create "SolNotes.Application" V-OBJSESSION no-error.

The progress app is started first which connects to lotus notes. Then a function is called in the DLL via progress to read the address book/contacts.
This is the area I am then wanting to store data in memory and pass the pointer back to progress.

P-ENTRY = V-OBJSESSION:getAlphaName ( P-LETTER ).

Getalphaname is a function defined within the DLL.


Thanks for your time.
 
The progress app is started first which connects to lotus notes. Then a function is called in the DLL via progress to read the address book/contacts.
This is the area I am then wanting to store data in memory and pass the pointer back to progress.

In that case it might be impossible because your progress session and your com object might be located in the different address spaces. But I'm not sure because it depends on what "SolNotes.Application" is. Could you find it in your registry and post its InprocServer32 key?
 
Jon100 said:
Location of the dll on my system.

C:\visualbasic\Lotus\SolNotes.dll

Looks like possible. But I have no idea about P4GL implementation of CREATE 'AcitiveX' because if it makes pure CreateObject your dll is loaded in PROGRESS address space where all pointers are valid.
 
?? Third part ??

Why not use the third party approach??
Dump out the required data to a text file from VB. Then execute a procedure that will read the data in the text file to use as appropriate eg. create new tables .... in Progress
You will need to define a common format for output-input
 
Back
Top