We have a delphi 7 dde client application that communicates with a dde server from another company ( ISIS Papyrus printing system ) Both are 32 bits and works fine on windows 7 32 bits.
Now our company is switching to windows 7 64 bits and the communication between the client and server doesn't work good anymore. We use a callback function with DdeInitialize
We use this because we want to know when the process done by the server is really finnished and the document is generated.
On windows 7 64bits we get roubbish data for PTMonMsgStruct(pData)^.wMsg
Anyone knows whats goes wrong ?
Code :
DdeInitialize(FDdeInstId, SVDdeCallBack, MF_POSTMSGS + MF_SENDMSGS, 0);
and the SVDdeCallBack
function SVDdeCallBack(
CallType, Fmt : UINT; //transaction type ; format atom of the data sent from the server
Conv: HConv; //a handle the conversation
hsz1, hsz2: HSZ; // hsz1: topic name ; hsz2: item name
Data: HDDEData; //a handle to the data associated with the topic and item name pair
Data1, Data2: ULONG) //
: HDDEData; stdcall;
var
pData: Pointer;
Len: Integer;
type
PTMonMsgStruct = ^TMonMsgStruct;
begin
Result := 0;
// Check if the calltype is the monitoring DDE call
if CallType = XTYP_MONITOR then
begin
// Get the DDE data
pData := DdeAccessData( Data, @Len);
// If data
if pData <> nil then
begin
// If data is a posted message
if Data2 = MF_POSTMSGS then
begin
try
// Check if the message was an acknowledge message
//myMonitorStruct := PTMonMsgStruct(pData^);
if PTMonMsgStruct(pData)^.wMsg = WM_DDE_ACK then
begin
WriteLogFile('prcDDE.DDECallBack: TMonMsgStruct(pData^).wMsg = WM_DDE_ACK');
WriteLogFile('prcDDE.DDECallBack: Acknowledge message');
// Detect only the acknowledge messages with no busy flag
if ((PTMonMsgStruct(pData)^.dmhd.uilo and DDE_FACK) = DDE_FACK) and
((PTMonMsgStruct(pData)^.dmhd.uilo and DDE_FBUSY) = 0) then
begin
// The DDE command has terminated
WriteLogFile('prcDDE.DDECallback: ((TMonMsgStruct(pData^).dmhd.uilo and DDE_FACK) = DDE_FACK) and ((TMonMsgStruct(pData^).dmhd.uilo and DDE_FBUSY) = 0)');
WriteLogFile('prcDDE.DDECallback: Acknowledge with BUSY Flag = 0');
ApplData.WaitStat := False;
WriteLogFile('prcDDE.DDECallback: ApplData.WaitStat := False');
end
else
begin
WriteLogFile('prcDDE.DDECallback: Acknowledge with BUSY Flag <> 0')
end;
end;
if PTMonMsgStruct(pData)^.wMsg = WM_DDE_TERMINATE then
begin
// Check if in close
WriteLogFile('prcDDE.DDECallBack:TMonMsgStruct(pData^).wMsg = WM_DDE_TERMINATE');
WriteLogFile('prcDDE.DDECallBack: DDE_terminate message');
if not scrFrontOffice.FInClose then
begin
// Check if there is a second file
if ((Length(ApplData.DataFile2) > 0) and (ApplData.DataFile <> ApplData.DataFile2)) then
begin
// Activate the timer
// 2 following commands removed by VDP -> added in PrcFrontOffice
if bInternWaitForView then
begin
scrFrontOffice.FTimerProcess := True;
scrFrontOffice.tmrClose.Enabled := True;
end;
end
else
begin
// The DDE connection is inactive
scrFrontOffice.FDDEConnectionActive := False;
// Close the program
scrFrontOffice.Close;
end;
end;
end;
finally
// Free the accessed data
DdeUnaccessData(Data);
end;
end
else
begin
//WriteLogFile('Data is no posted message');
end;
end
else
begin
//WriteLogFile('No data received with DdeAccessData');
end;
end;
end;
DDEInitializeand have verified that it isDMLERR_NO_ERROR? Otherwise, likely DDE problems are often win7 installations being not up to date (some bad KBs have trashed DDE in the past), antivirus applications blocking DDE messages, bad hardware drivers, UAC issues... DDE is pretty fragile - it's almost 30 years old and has been dead for almost 20. Not really enough information here to be able to help, unfortunately. - J...