The MASM Forum Archive 2004 to 2012

General Forums => The Laboratory => Topic started by: ecube on December 20, 2008, 01:53:03 AM

Title: dde multithread issues
Post by: ecube on December 20, 2008, 01:53:03 AM
can someone please tell me why dde doesn't seem to work if I try and use the functions in a new thread? I've written code that if called within the original thread works but if in a new thread it absolutely doesn't...says invalid parameter. I've tried everything, can't get it to work, here's a simple example to show what I mean


.686
.model flat,stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
ddefunc proto
DDECallBack PROTO :DWORD, :DWORD,:DWORD,:DWORD, :DWORD,:DWORD, :DWORD, :DWORD
.data
teststring byte 'teststring',0

.data?
hconv_ dd ?
ddeid                         dd ?

.code
start:
invoke CreateThread,0,0,addr ddefunc,0,0,0
invoke CloseHandle,eax
@sleeptime:
invoke Sleep,8000
jmp @sleeptime


ddefunc proc
invoke DdeInitialize, addr ddeid, addr DDECallBack, APPCLASS_STANDARD,0
invoke DdeCreateStringHandle,ddeid,addr teststring,CP_WINANSI
invoke DDeGetLastError,ddeid
ret
ddefunc endp

DDECallBack PROC uType:DWORD, uFmt:DWORD, hconv:DWORD, hsz1:DWORD, hsz2:DWORD,hdata:DWORD, dwData1:DWORD, dwData2:DWORD
xor eax, eax
ret
DDECallBack endp
end start

the ddecreatestringhandle is where it errors says invalid parameter, i've tried countless things for the params, the addr testring I tried copying the contents to a global buffer and sending that first, I tried globalloc mem doesn't work either, in the single thread app it works fine. i'm using ddespy that came with visual studio 6.0 to see everythings thats going on...
Title: Re: dde multithread issues
Post by: ecube on December 20, 2008, 07:55:10 AM
APPCMD_CLIENTONLY fixed it, replaced APPCLASS_STANDARD, funny how frustrated one can get when the answers starring you in the face all along.