News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

masm and dde

Started by darrenls59, September 15, 2007, 12:08:48 AM

Previous topic - Next topic

darrenls59

I posted an article on a win32 newsgroup among other places but either they don't know DDE or they don't know masm.

Hi all. I'm hoping this is the right place to code this but has anyone had any success with writing dde aplications in masm? I got something coded that initialises dde and connects to the server ok but doesn't retrieve data. I handed a ddecallback callback function to DdeInitialize but regadless of what events i tell DDE to watch or not to watch it never invokes the callback function. I tried to call DdeQueryString after a successful connec but it retuns 8 bytes of garbage. What I'm looking for is for a code that will respond whenver the dde object i am watching changes and also checks it at startup. if this is not possible then i would happily poll the dde item periodically.. I've googled but everything seems to be in visual basic which i tried to map over but it didn't work.

Any ideas?

Thanks.

ToutEnMasm

#1
Hello,
I have written this.
Comments are in french but source is made to understand how dde work and made your own source.
Add any questions here,I will answer its.
2011    added a zip
                                 






[attachment deleted by admin]

darrenls59

Quote from: ToutEnMasm on September 17, 2007, 07:03:51 PM
Hello,
I have written this.
http://perso.orange.fr/luce.yves/DDE.zip

Comments are in french but source is made to understand how dde work and made your own source.
Add any questions here,I will answer its.


Thank you. What IDE did you use? I do not recongnise the edm extension.

I got my client to retrive data from the server and i got it to notify my when server disconnects from the callback function using XTYP_DISCONNECT but for some reason Ican't get it to respond to XTYP_ADVDATA. Is there something i need to set up especially for this event to trigger?

Merci. :)

ToutEnMasm

Hello,
My IDE is of mine,Editmasm downloadable on my site.
edm are rtf files that you can view after renamed them in *.rtf (word).They are the same as the asm one with formatted text,images,colors...

The message you speak is part of DDEML.
Follow this steps to send a text to the server.

Run serveur.exe , in the menu DDEML choose "Init du serveur"   
This message is generated
Quote
XTYP_REGISTER

Run client.exe,and follow this steps in the DDEML menu.

1) "Initialisation"        (in english 'init of the client')
2) "Préparer la conversation"   (in english 'init for a talk')
3) "Envoyer un paquet" (in english 'send a paqued text')

Then you can see how many server you have on your computer
4) "liste des serveurs" (servers list)

The edit of the client must show

Quote
WM_DDE_INITIATE
WM_DDE_INITIATE
XTYP_MONITOR MF_CONV Folders | AppProperties
XTYP_MONITOR MF_CONV Shell | AppProperties
XTYP_MONITOR MF_CONV PROGMAN | PROGMAN
XTYP_MONITOR MF_CONV soffice | System
XTYP_MONITOR MF_CONV KCLECIFFOSGIFNOCRESU2GROECIFFONEPOATAD02NOITACILPPAECULSGNITTES02DNA02STNEMUCODCELIF | System
XTYP_MONITOR MF_CONV essai | test
XTYP_MONITOR MF_CONV
XTYP_MONITOR MF_CONV


The edit of the server

Quote

XTYP_REGISTER
XTYP_CONNECT
XTYP_CONNECT_CONFIRM
XTYP_POKE



XTYP_POKE


Ceci est un paquet de texte
ORIGINE CLIENT
Destiné a illustré le passage
de données par DDEML
1° DdeInitialize,addr HddeInst,offset CallBackDDE,APPCLASS_STANDARD,0
2° remplir CONVCONTEXT optionnel
3° DdeCreateStringHandle,HddeInst,addr ServiceName
4° DdeNameService,HddeInst,HServiceName
5° adapter CallBackDDE a serveur ou client


XTYP_DISCONNECT
WM_DDE_INITIATE
XTYP_WILDCONNECT
XTYP_WILDCONNECT
XTYP_CONNECT_CONFIRM
XTYP_DISCONNECT



The text show you the most important API used and say that filling CONVCONTEXT with data is optionnal.


 



















darrenls59

Quote from: ToutEnMasm on September 18, 2007, 03:17:43 PM
Hello,
My IDE is of mine,Editmasm downloadable on my site.
edm are rtf files that you can view after renamed them in *.rtf (word).They are the same as the asm one with formatted text,images,colors...

The message you speak is part of DDEML.
Follow this steps to send a text to the server.

Run serveur.exe , in the menu DDEML choose "Init du serveur"   
This message is generated
Quote
XTYP_REGISTER

Run client.exe,and follow this steps in the DDEML menu.

1) "Initialisation"        (in english 'init of the client')
2) "Préparer la conversation"   (in english 'init for a talk')
3) "Envoyer un paquet" (in english 'send a paqued text')

Then you can see how many server you have on your computer
4) "liste des serveurs" (servers list)

The edit of the client must show

Quote
WM_DDE_INITIATE
WM_DDE_INITIATE
XTYP_MONITOR MF_CONV Folders | AppProperties
XTYP_MONITOR MF_CONV Shell | AppProperties
XTYP_MONITOR MF_CONV PROGMAN | PROGMAN
XTYP_MONITOR MF_CONV soffice | System
XTYP_MONITOR MF_CONV KCLECIFFOSGIFNOCRESU2GROECIFFONEPOATAD02NOITACILPPAECULSGNITTES02DNA02STNEMUCODCELIF | System
XTYP_MONITOR MF_CONV essai | test
XTYP_MONITOR MF_CONV
XTYP_MONITOR MF_CONV


The edit of the server

Quote

XTYP_REGISTER
XTYP_CONNECT
XTYP_CONNECT_CONFIRM
XTYP_POKE



XTYP_POKE


Ceci est un paquet de texte
ORIGINE CLIENT
Destiné a illustré le passage
de données par DDEML
1° DdeInitialize,addr HddeInst,offset CallBackDDE,APPCLASS_STANDARD,0
2° remplir CONVCONTEXT optionnel
3° DdeCreateStringHandle,HddeInst,addr ServiceName
4° DdeNameService,HddeInst,HServiceName
5° adapter CallBackDDE a serveur ou client


XTYP_DISCONNECT
WM_DDE_INITIATE
XTYP_WILDCONNECT
XTYP_WILDCONNECT
XTYP_CONNECT_CONFIRM
XTYP_DISCONNECT



The text show you the most important API used and say that filling CONVCONTEXT with data is optionnal.


Cool. No I mean I've written a client that gets data from a programm called satscape. my programme works fine re connecting and aquiring data manually but fails to respond  I think it's something to do with an advice loop but I don't know.

ToutEnMasm

Hello,
If you don't know what error you have,re write your code in my sources files and test it.Errors can be reported in the edit window as follow.
The proc RetrouveMesErreurDDEML use the API DdeGetLastError and write the error in the edit window.
With the DDEML messages and the reported errors in the edit window,you have all the necessary to find an answer.
If not,post it here,I will have a look on it.

The most important is the CallBackDDE proc.Verify that this one return the corrects values.

Have a look also at the RecherCherListe proc,this one made a list of the servers.
To do that,he need to modify the connection parameters that was good to send the text.
The parameters are saved and restored after the work.





darrenls59

Quote from: ToutEnMasm on September 19, 2007, 06:14:40 AM
Hello,
If you don't know what error you have,re write your code in my sources files and test it.Errors can be reported in the edit window as follow.
The proc RetrouveMesErreurDDEML use the API DdeGetLastError and write the error in the edit window.

That's the point. I'm not getting errors anywhere. Nohing seems to actually fail.
I'm wondering if satscape simply doesn' handle advice loops. If this is the case shouldn't it inform the client when it requests one?

Quote
With the DDEML messages and the reported errors in the edit window,you have all the necessary to find an answer.
If not,post it here,I will have a look on it.

The most important is the CallBackDDE proc.Verify that this one return the corrects values.

Have a look also at the RecherCherListe proc,this one made a list of the servers.
To do that,he need to modify the connection parameters that was good to send the text.
The parameters are saved and restored after the work.






alright,

Here is the data section

.const

ClassName         db 'DLGCLASS',0
AppName            db 'rotorcontroller',0
AboutMsg         db 'Rotor controller ',13,10,'Copyright © G7WAP 2007',0
DDEerr            db 'DDE Error, is satscape rotor running',0
DDEok            db 'DDE link established',0
Satscape         db 'Satscape',0
Tracking         db 'Tracking',0
DDEFail            db 'DDE failed to initialise',0
ErrorSTR         db 'Error',0
SatscapeTerminated   db 'Satscape Interface terminated',0
dummy_text         db 'dummy text',0
parallel_port      db 'LPT1:',0

.data?

hInstance         dd ?
CommandLine         dd ?
hWnd            dd ?
handle1            dd ?
handle2            dd ?
handle3            dd ?
conv            dd ?
ddeInstance         dd ?
textfield         dd ?
data_handle         dd ?
textptr            dd ?
ddelasterror      dd ?
data_size         dd ?

.data

buf               db 255 dup(0)
temp            db 255 dup (0)
newline          db 13,10,0
lEditBox         dd   0




Here's the bit that sets the loop up

invoke DdeCreateStringHandle, ddeInstance, addr Satscape, CP_WINANSI
   
   or eax,eax
   jz failed_it
   mov handle1, eax
   invoke DdeCreateStringHandle, ddeInstance, addr Tracking, CP_WINANSI
   
   or eax,eax
   jz failed_it
   
   mov handle2, eax
   invoke DdeConnect, ddeInstance, handle1, handle2,0
   
   or eax,eax
   jz failed_it
   mov conv,eax
   
   
   invoke DdeCreateStringHandle,ddeInstance, addr Tracking,CP_WINANSI
   or eax,eax
   jz failed_it

   mov handle3, eax
   
      
   
   invoke  DdeClientTransaction,0,0,conv,handle3,CF_TEXT,XTYP_ADVSTART or XTYPF_NODATA,5000,0

   or eax,eax
   jz failed_it
   mov data_handle,eax
   

here's my DDE callback function.
Not, the XTYP_DISCONNECT works fine but the XTYP_ADVDATA never responds and the data it looks at changes once per second.


ddecallback proc uType:UINT,uFmt:UINT, hconv:HCONV, hszTopic:HSZ, hszItem:HSZ, hdata:HDDEDATA,  dwData1:DWORD, dwData2:DWORD


.if  uType== XTYP_DISCONNECT
      invoke addlogtext, addr SatscapeTerminated
      mov eax,0
      ret

      
   

.elseif uType== XTYP_ADVDATA
   invoke addlogtext, addr dummy_text
   .if uFmt != CF_TEXT
      mov eax,DDE_FNOTPROCESSED
      ret
   .else
      
      invoke addlogtext, addr DDEok
      mov eax,DDE_FACK
      ret 
      
   .endif

      

   
   


.endif


   ret
   
ddecallback endp

ToutEnMasm

Hello,
I have downloded satscape and his documentation.

The author say,with excel put '=Satscape|Tracking!Tracking' in a cell.
This don't work,excel don't find this name.

I have made a list of the servers with my client,no more Satcape as a server.

The author say that Wisp-DDE is abble to communicate with satscape.I run it.
I try to make a list of the servers with my client and this time,wispdde was detected as a server.
But .... wispdde go to crash.


Finally,satscape beeing not a server,wispdde crashing,you have no other choice than write to the author and tell him the results of the tests i have made.







darrenls59

Quote from: ToutEnMasm on September 20, 2007, 03:59:37 PM
Hello,
I have downloded satscape and his documentation.

The author say,with excel put '=Satscape|Tracking!Tracking' in a cell.
This don't work,excel don't find this name.

I have made a list of the servers with my client,no more Satcape as a server.

The author say that Wisp-DDE is abble to communicate with satscape.I run it.
I try to make a list of the servers with my client and this time,wispdde was detected as a server.
But .... wispdde go to crash.


Finally,satscape beeing not a server,wispdde crashing,you have no other choice than write to the author and tell him the results of the tests i have made.



In Satscape you have to enable the DDE by clicking "radio/rotor" control on the satscape launch pad. Then excel aut updates which means that satscape must listen for the XTYP_ADVDATA or something similar but when the data changes, the callback function isn't even invoked. I don't get it.




ToutEnMasm


OK,with the rotor/radio button on ,and selected the moon as sattelite, excel diplay the result in loop.
my cell is like that SNmoon
AZ161,70 EL60,45 DO24,0392329915601
and then
SNmoon AZ161,91 EL60,49 DO23,7407441854437
.........
Now i can write someting to do the same

darrenls59

Quote from: ToutEnMasm on September 20, 2007, 06:07:31 PM

OK,with the rotor/radio button on ,and selected the moon as sattelite, excel diplay the result in loop.
my cell is like that SNmoon
AZ161,70 EL60,45 DO24,0392329915601
and then
SNmoon AZ161,91 EL60,49 DO23,7407441854437
.........
Now i can write someting to do the same

Cool. but I just want to know what I'm doing wrong.


ToutEnMasm

Hello,
I am reviewing my code.
We can proceed step by step
I am at ddeconnect and with my code i receive
Quote
WM_DDE_INITIATE
XTYP_REGISTER

In the edit window.Connection with my code is OK.
I don't see what is wrong with your code except that he could'nt generate a report on the transactions as mine.
I perform more tests and post my code when it is finished.


ToutEnMasm


Solved,
The good transaction for the server is XTYP_REQUEST


After a succesfull connection
tr.Hconv = handle of conversation (Satscape|Tracking )
tr.HRubrique = string handle of Tracking (re-use the one for establish the talk)

Quote
      invoke DdeClientTransaction,HDDEDATA,0FFFFFFFFh,tr.Hconv,tr.HRubrique,\
            CF_TEXT,XTYP_REQUEST,TIMEOUT_ASYNC,addr tr.pdwResult
      mov Huser,eax
      .if eax == 0
         invoke RetrouveMesErreurDDEML,tr.HddeInst,SADR("DdeCreateStringHandle")   
         mov retour,0
         jmp FindeOuvrirConversationDDEML
      .endif
      invoke DdeGetData,Huser,addr ReceptData,sizeof ReceptData,0
      
      invoke DdeFreeDataHandle,Huser
      ;
      invoke szCatStr,addr ReceptData,addr retourligne
      invoke szCatStr,addr ReceptData,addr retourligne      
      invoke SendMessage,HRedit,EM_SETSEL,-1,0  ;bout de texte
      invoke SendMessage,HRedit,EM_REPLACESEL,FALSE,addr ReceptData  ;pas de undo,impossible d'effacer      
      ;invoke MessageBox,NULL,ADDR ReceptData,ADDR TxtRecept,MB_OK

Using my client,the edit window is like that
Quote
WM_DDE_INITIATE
SNmoon AZ130,61 EL-47,92 DO78,9283187339271







darrenls59

Quote from: ToutEnMasm on September 21, 2007, 09:51:14 AM

Solved,
The good transaction for the server is XTYP_REQUEST


After a succesfull connection
tr.Hconv = handle of conversation (Satscape|Tracking )
tr.HRubrique = string handle of Tracking (re-use the one for establish the talk)

Quote
      invoke DdeClientTransaction,HDDEDATA,0FFFFFFFFh,tr.Hconv,tr.HRubrique,\
            CF_TEXT,XTYP_REQUEST,TIMEOUT_ASYNC,addr tr.pdwResult
      mov Huser,eax
      .if eax == 0
         invoke RetrouveMesErreurDDEML,tr.HddeInst,SADR("DdeCreateStringHandle")   
         mov retour,0
         jmp FindeOuvrirConversationDDEML
      .endif
      invoke DdeGetData,Huser,addr ReceptData,sizeof ReceptData,0
      
      invoke DdeFreeDataHandle,Huser
      ;
      invoke szCatStr,addr ReceptData,addr retourligne
      invoke szCatStr,addr ReceptData,addr retourligne      
      invoke SendMessage,HRedit,EM_SETSEL,-1,0  ;bout de texte
      invoke SendMessage,HRedit,EM_REPLACESEL,FALSE,addr ReceptData  ;pas de undo,impossible d'effacer      
      ;invoke MessageBox,NULL,ADDR ReceptData,ADDR TxtRecept,MB_OK

Using my client,the edit window is like that
Quote
WM_DDE_INITIATE
SNmoon AZ130,61 EL-47,92 DO78,9283187339271

I'm with you but I already got data with XTYP_REQUEST. That bit took me a while to figure out but what I couldn't solve is why my programme doesn't respond to XTYP_ADVDATA. Despite the fact that excel manages too. Did you have any luck with that? Sorry if I'm such a pain.








ToutEnMasm

Hello,
I am lucky this day
I put only the new DdeClientTransaction

Quote
      invoke DdeClientTransaction,NULL,NULL,tr.Hconv,tr.HRubrique,\
            CF_TEXT,XTYP_ADVSTART + XTYPF_NODATA,TIMEOUT_ASYNC,addr tr.pdwResult
      mov Huser,eax

And what i have in my edit window ?

Quote
WM_DDE_INITIATE


XTYP_ADVDATA
XTYP_ADVDATA
XTYP_ADVDATA
XTYP_ADVDATA
XTYP_ADVDATA
....

The XTYP_ADVDATA is sended in loop to the client.Modify it in the CallBackDDE proc.
I lets you write what is needed in the XTYP_ADVDATA message but perhaps are you unlucky ?

  :bg  :bg  :bg  :bg
                              :toothy