Additionally, I should've referred to RtlMoveMemory, not it's alias of CopyMemory !
(I'll get PowerBasic worked out - just let me master English first)

------------------
FUNCTION SEND2VB() EXPORT AS INTEGER ON ERROR RESUME NEXT DIM cds AS COPYDATASTRUCT DIM Buf(255) AS BYTE DIM hFound& hFound& = FindWindow("", "DDE Target Window") Buff$ = "Hello, anybody there?" CALL MoveMemory(BYVAL VARPTR(Buf(0)), BYVAL STRPTR(Buff$), LEN(Buff$)) cds.dwData = 3 cds.cbData = LEN(Buff$) + 1 cds.lpData = VARPTR(Buf(0)) CALL SendMessage(hFound&, %WM_COPYDATA, 0, VARPTR(cds)) FUNCTION = 1 'Success, cheers Lance/Patrice! END FUNCTION
CALL MoveMemory(BYVAL VARPTR(Buf(0)), BYVAL STRPTR(Buff$), LEN(Buff$))
POKE$ VARPTR(Buf(0)), LEFT$(Buff$, UBOUND(Buf()) - LBOUND(Buf()))
DECLARE SUB CopyMemory LIB "KERNEL32.DLL" ALIAS "RtlMoveMemory" (lpDest AS ANY, lpSource AS ANY, BYVAL cb&) ' SEND PART DIM cds As COPYDATASTRUCT DIM Buf(255) AS BYTE Buff$ = "The string to send" CALL CopyMemory(Buf(0), BYVAL STRPTR(Buff$), LEN(Buff$)) cds.dwData = 3 cds.cbData = LEN(Buff$) + 1 cds.lpData = VARPTR(Buf(0)) CALL SendMessage(hFound&, %WM_COPYDATA, 0, VARPTR(cds)) 'RECEPT PART CASE %WM_COPYDATA DIM cds AS COPYDATASTRUCT DIM Buf(255) AS BYTE CALL CopyMemory(cds, BYVAL lParam&, SIZEOF(cds)) SELECT CASE cds.dwData CASE 1 CASE 2 CASE 3 Call CopyMemory(buf(0), BYVAL cds.lpData, cds.cbData) Buff$ = PEEK$(VARPTR(buf(0)), UBOUND(Buf) - LBOUND(Buf) + 1) So& = INSTR(Buff$, CHR$(0)) IF So& THEN Buff$ = LEFT$(Buff$, So& -1) MsgBox Buff$ END SELECT
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Leave a comment: