4 * Copyright 1997 Alexandre Julliard
5 * Copyright 1997 Len White
6 * Copyright 1999 Keith Matthews
9 /* Only empty stubs for now */
18 #include "debugtools.h"
22 DEFAULT_DEBUG_CHANNEL(ddeml
)
24 /* Has defined in atom.c file.
26 #define MAX_ATOM_LEN 255
28 /* Maximum buffer size ( including the '\0' ).
30 #define MAX_BUFFER_LEN (MAX_ATOM_LEN + 1)
34 LPVOID lpSecurityDescriptor;
36 } SECURITY_ATTRIBUTES; */
38 /* This is a simple list to keep track of the strings created
39 * by DdeCreateStringHandle. The list is used to free
40 * the strings whenever DdeUninitialize is called.
41 * This mechanism is not complete and does not handle multiple instances.
42 * Most of the DDE API use a DWORD parameter indicating which instance
43 * of a given program is calling them. The API are supposed to
44 * associate the data to the instance that created it.
46 typedef struct tagHSZNode HSZNode
;
54 typedef struct tagServiceNode ServiceNode
;
61 typedef struct DDE_HANDLE_ENTRY
{
62 BOOL16 Monitor
; /* have these two as full Booleans cos they'll be tested frequently */
63 BOOL16 Client_only
; /* bit wasteful of space but it will be faster */
64 BOOL16 Unicode
; /* Flag to indicate Win32 API used to initialise */
65 BOOL16 Win16
; /* flag to indicate Win16 API used to initialize */
66 DWORD Instance_id
; /* needed to track monitor usage */
67 struct DDE_HANDLE_ENTRY
*Next_Entry
;
72 UINT Txn_count
; /* count transactions open to simplify closure */
74 ServiceNode
* ServiceNames
;
77 static DDE_HANDLE_ENTRY
*DDE_Handle_Table_Base
= NULL
;
78 static DWORD DDE_Max_Assigned_Instance
= 0; /* OK for present, may have to worry about wrap-around later */
79 static const char *DDEInstanceAccess
= "DDEMaxInstance";
80 static const char *DDEHandleAccess
= "DDEHandleAccess";
81 static HANDLE inst_count_mutex
= 0;
82 static HANDLE handle_mutex
= 0;
88 /******************************************************************************
89 * RemoveHSZNodes (INTERNAL)
91 * Remove a node from the list of HSZ nodes.
93 ******************************************************************************
97 * Vn Date Author Comment
99 * 1.0 Dec 1998 Corel/Macadamian Initial version
100 * 1.1 Mar 1999 Keith Matthews Added multiple instance handling
103 static void RemoveHSZNode( HSZ hsz
, DDE_HANDLE_ENTRY
* reference_inst
)
105 HSZNode
* pPrev
= NULL
;
106 HSZNode
* pCurrent
= NULL
;
108 /* Set the current node at the start of the list.
110 pCurrent
= reference_inst
->Node_list
;
111 /* While we have more nodes.
113 while( pCurrent
!= NULL
)
115 /* If we found the node we were looking for.
117 if( pCurrent
->hsz
== hsz
)
121 /* If the first node in the list is to to be removed.
122 * Set the global list pointer to the next node.
124 if( pCurrent
== reference_inst
->Node_list
)
126 reference_inst
->Node_list
= pCurrent
->next
;
128 /* Just fix the pointers has to skip the current
129 * node so we can delete it.
133 pPrev
->next
= pCurrent
->next
;
135 /* Destroy this node.
140 /* Save the previous node pointer.
143 /* Move on to the next node.
145 pCurrent
= pCurrent
->next
;
149 /******************************************************************************
150 * FreeAndRemoveHSZNodes (INTERNAL)
152 * Frees up all the strings still allocated in the list and
153 * remove all the nodes from the list of HSZ nodes.
155 ******************************************************************************
159 * Vn Date Author Comment
161 * 1.0 Dec 1998 Corel/Macadamian Initial version
162 * 1.1 Mar 1999 Keith Matthews Added multiple instance handling
165 static void FreeAndRemoveHSZNodes( DWORD idInst
, DDE_HANDLE_ENTRY
* reference_inst
)
167 /* Free any strings created in this instance.
169 while( reference_inst
->Node_list
!= NULL
)
171 DdeFreeStringHandle( idInst
, reference_inst
->Node_list
->hsz
);
175 /******************************************************************************
176 * InsertHSZNode (INTERNAL)
178 * Insert a node to the head of the list.
180 ******************************************************************************
184 * Vn Date Author Comment
186 * 1.0 Dec 1998 Corel/Macadamian Initial version
187 * 1.1 Mar 1999 Keith Matthews Added instance handling
188 * 1.2 Jun 1999 Keith Matthews Added Usage count handling
191 static void InsertHSZNode( HSZ hsz
, DDE_HANDLE_ENTRY
* reference_inst
)
195 HSZNode
* pNew
= NULL
;
196 /* Create a new node for this HSZ.
198 pNew
= (HSZNode
*) malloc( sizeof( HSZNode
) );
201 /* Set the handle value.
204 /* Attach the node to the head of the list. i.e most recently added is first
206 pNew
->next
= reference_inst
->Node_list
;
208 /* The new node is now at the head of the list
209 * so set the global list pointer to it.
211 reference_inst
->Node_list
= pNew
;
212 TRACE("HSZ node list entry added\n");
217 /*****************************************************************************
218 * Find_Instance_Entry
220 * generic routine to return a pointer to the relevant DDE_HANDLE_ENTRY
221 * for an instance Id, or NULL if the entry does not exist
223 * ASSUMES the mutex protecting the handle entry list is reserved before calling
225 ******************************************************************************
229 * Vn Date Author Comment
231 * 1.0 March 1999 Keith Matthews 1st implementation
233 DDE_HANDLE_ENTRY
*Find_Instance_Entry (DWORD InstId
)
235 DDE_HANDLE_ENTRY
* reference_inst
;
236 reference_inst
= DDE_Handle_Table_Base
;
237 while ( reference_inst
!= NULL
)
239 if ( reference_inst
->Instance_id
== InstId
)
241 TRACE("Instance entry found\n");
242 return reference_inst
;
244 reference_inst
= reference_inst
->Next_Entry
;
246 TRACE("Instance entry missing\n");
250 /*****************************************************************************
253 * generic routine to return a pointer to the relevant ServiceNode
254 * for a given service name, or NULL if the entry does not exist
256 * ASSUMES the mutex protecting the handle entry list is reserved before calling
258 ******************************************************************************
262 * Vn Date Author Comment
264 * 1.0 May 1999 Keith Matthews 1st implementation
266 ServiceNode
*Find_Service_Name (HSZ Service_Name
, DDE_HANDLE_ENTRY
* this_instance
)
268 ServiceNode
* reference_name
= this_instance
->ServiceNames
;
269 while ( reference_name
!= NULL
)
271 if ( reference_name
->hsz
== Service_Name
)
273 TRACE("Service Name found\n");
274 return reference_name
;
276 reference_name
= reference_name
->next
;
278 TRACE("Service name missing\n");
283 /******************************************************************************
284 * Release_reserved_mutex
286 * generic routine to release a reserved mutex
289 ******************************************************************************
293 * Vn Date Author Comment
295 * 1.0 Jan 1999 Keith Matthews Initial version
296 * 1.1 Mar 1999 Keith Matthews Corrected Heap handling. Corrected re-initialisation handling
297 * 1.2 Aug 1999 Jürgen Schmied Corrected error handling
300 static DWORD
Release_reserved_mutex (HANDLE mutex
, LPSTR mutex_name
, BOOL release_handle_m
, BOOL release_this_i
,
301 DDE_HANDLE_ENTRY
*this_instance
)
303 if (!ReleaseMutex(mutex
))
305 ERR("ReleaseMutex failed - %s mutex %li\n",mutex_name
,GetLastError());
306 HeapFree(SystemHeap
, 0, this_instance
);
307 if ( release_handle_m
)
309 ReleaseMutex(handle_mutex
);
311 return DMLERR_SYS_ERROR
;
313 if ( release_this_i
)
315 HeapFree(SystemHeap
, 0, this_instance
);
317 return DMLERR_NO_ERROR
;
320 /******************************************************************************
323 * generic routine to wait for the mutex
326 ******************************************************************************
330 * Vn Date Author Comment
332 * 1.0 Aug 1999 Juergen Schmied Initial version
335 static BOOL
WaitForMutex (HANDLE mutex
)
339 result
= WaitForSingleObject(mutex
,1000);
341 /* both errors should never occur */
342 if (WAIT_TIMEOUT
== result
)
344 ERR("WaitForSingleObject timed out\n");
348 if (WAIT_FAILED
== result
)
350 ERR("WaitForSingleObject failed - error %li\n", GetLastError());
355 /******************************************************************************
356 * IncrementInstanceId
358 * generic routine to increment the max instance Id and allocate a new application instance
360 ******************************************************************************
364 * Vn Date Author Comment
366 * 1.0 Jan 1999 Keith Matthews Initial version
369 DWORD
IncrementInstanceId( DDE_HANDLE_ENTRY
*this_instance
)
371 SECURITY_ATTRIBUTES s_attrib
;
373 /* Need to set up Mutex in case it is not already present */
374 /* increment handle count & get value */
375 if ( !inst_count_mutex
)
377 s_attrib
.bInheritHandle
= TRUE
;
378 s_attrib
.lpSecurityDescriptor
= NULL
;
379 s_attrib
.nLength
= sizeof(s_attrib
);
380 inst_count_mutex
= CreateMutexA(&s_attrib
,1,DDEInstanceAccess
); /* 1st time through */
381 inst_count_mutex
= ConvertToGlobalHandle(inst_count_mutex
); /* fixme when having seperate adresspaces*/
383 if ( !WaitForMutex(inst_count_mutex
) )
385 return DMLERR_SYS_ERROR
;
388 if ( !inst_count_mutex
)
390 ERR("CreateMutex failed - inst_count %li\n",GetLastError());
391 Release_reserved_mutex (handle_mutex
,"handle_mutex",0,1,this_instance
);
392 return DMLERR_SYS_ERROR
;
394 DDE_Max_Assigned_Instance
++;
395 this_instance
->Instance_id
= DDE_Max_Assigned_Instance
;
396 TRACE("New instance id %ld allocated\n",DDE_Max_Assigned_Instance
);
397 if (Release_reserved_mutex(inst_count_mutex
,"instance_count",1,0,this_instance
)) return DMLERR_SYS_ERROR
;
398 return DMLERR_NO_ERROR
;
401 /******************************************************************************
402 * FindNotifyMonitorCallbacks
404 * Routine to find instances that need to be notified via their callback
405 * of some event they are monitoring
407 ******************************************************************************
411 * Vn Date Author Comment
413 * 1.0 May 1999 Keith Matthews Initial Version
417 void FindNotifyMonitorCallbacks(DWORD ThisInstance
, DWORD DdeEvent
)
419 DDE_HANDLE_ENTRY
*InstanceHandle
;
420 InstanceHandle
= DDE_Handle_Table_Base
;
421 while ( InstanceHandle
!= NULL
)
423 if ( (InstanceHandle
->Monitor
) && InstanceHandle
->Instance_id
== ThisInstance
)
425 /* Found an instance registered as monitor and is not ourselves
426 * use callback to notify where appropriate
429 InstanceHandle
= InstanceHandle
->Next_Entry
;
433 /******************************************************************************
436 * Routine to make an extra Add on an atom to reserve it a bit longer
438 ******************************************************************************
442 * Vn Date Author Comment
444 * 1.0 Jun 1999 Keith Matthews Initial Version
448 static void DdeReserveAtom( DDE_HANDLE_ENTRY
* reference_inst
,HSZ hsz
)
450 if ( reference_inst
->Unicode
)
452 WCHAR SNameBuffer
[MAX_BUFFER_LEN
];
453 GlobalGetAtomNameW(hsz
,SNameBuffer
,MAX_BUFFER_LEN
);
454 GlobalAddAtomW(SNameBuffer
);
456 CHAR SNameBuffer
[MAX_BUFFER_LEN
];
457 GlobalGetAtomNameA(hsz
,SNameBuffer
,MAX_BUFFER_LEN
);
458 GlobalAddAtomA(SNameBuffer
);
463 /******************************************************************************
466 * Routine to make a delete on an atom to release it a bit sooner
468 ******************************************************************************
472 * Vn Date Author Comment
474 * 1.0 Jun 1999 Keith Matthews Initial Version
478 static void DdeReleaseAtom( DDE_HANDLE_ENTRY
* reference_inst
,HSZ hsz
)
480 GlobalDeleteAtom( hsz
);
483 /******************************************************************************
484 * DdeInitialize16 (DDEML.2)
486 UINT16 WINAPI
DdeInitialize16( LPDWORD pidInst
, PFNCALLBACK16 pfnCallback
,
487 DWORD afCmd
, DWORD ulRes
)
489 TRACE("DdeInitialize16 called - calling DdeInitializeA\n");
490 return (UINT16
)DdeInitializeA(pidInst
,(PFNCALLBACK
)pfnCallback
,
495 /******************************************************************************
496 * DdeInitializeA (USER32.106)
498 UINT WINAPI
DdeInitializeA( LPDWORD pidInst
, PFNCALLBACK pfnCallback
,
499 DWORD afCmd
, DWORD ulRes
)
501 TRACE("DdeInitializeA called - calling DdeInitializeW\n");
502 return DdeInitializeW(pidInst
,pfnCallback
,afCmd
,ulRes
);
506 /******************************************************************************
507 * DdeInitializeW [USER32.107]
508 * Registers an application with the DDEML
511 * pidInst [I] Pointer to instance identifier
512 * pfnCallback [I] Pointer to callback function
513 * afCmd [I] Set of command and filter flags
517 * Success: DMLERR_NO_ERROR
518 * Failure: DMLERR_DLL_USAGE, DMLERR_INVALIDPARAMETER, DMLERR_SYS_ERROR
520 ******************************************************************************
524 * Vn Date Author Comment
526 * 1.0 Pre 1998 Alexandre/Len Initial Stub
527 * 1.1 Jan 1999 Keith Matthews Initial (near-)complete version
528 * 1.2 Mar 1999 Keith Matthews Corrected Heap handling, CreateMutex failure handling
531 UINT WINAPI
DdeInitializeW( LPDWORD pidInst
, PFNCALLBACK pfnCallback
,
532 DWORD afCmd
, DWORD ulRes
)
535 /* probably not really capable of handling multiple processes, but should handle
536 * multiple instances within one process */
538 SECURITY_ATTRIBUTES
*s_att
= NULL
;
539 SECURITY_ATTRIBUTES s_attrib
;
541 DDE_HANDLE_ENTRY
*this_instance
;
542 DDE_HANDLE_ENTRY
*reference_inst
;
547 ERR("Reserved value not zero? What does this mean?\n");
548 FIXME("(%p,%p,0x%lx,%ld): stub\n", pidInst
, pfnCallback
,
550 /* trap this and no more until we know more */
551 return DMLERR_NO_ERROR
;
555 /* this one may be wrong - MS dll seems to accept the condition,
556 leave this until we find out more !! */
559 /* can't set up the instance with nothing to act as a callback */
560 TRACE("No callback provided\n");
561 return DMLERR_INVALIDPARAMETER
; /* might be DMLERR_DLL_USAGE */
564 /* grab enough heap for one control struct - not really necessary for re-initialise
565 * but allows us to use same validation routines */
566 this_instance
= (DDE_HANDLE_ENTRY
*)HeapAlloc( SystemHeap
, 0, sizeof(DDE_HANDLE_ENTRY
) );
567 if ( this_instance
== NULL
)
569 /* catastrophe !! warn user & abort */
570 ERR("Instance create failed - out of memory\n");
571 return DMLERR_SYS_ERROR
;
573 this_instance
->Next_Entry
= NULL
;
574 this_instance
->Monitor
=(afCmd
|APPCLASS_MONITOR
);
576 /* messy bit, spec implies that 'Client Only' can be set in 2 different ways, catch 1 here */
578 this_instance
->Client_only
=afCmd
&APPCMD_CLIENTONLY
;
579 this_instance
->Instance_id
= *pidInst
; /* May need to add calling proc Id */
580 this_instance
->CallBack
=*pfnCallback
;
581 this_instance
->Txn_count
=0;
582 this_instance
->Unicode
= TRUE
;
583 this_instance
->Win16
= FALSE
;
584 this_instance
->Node_list
= NULL
; /* node will be added later */
585 this_instance
->Monitor_flags
= afCmd
& MF_MASK
;
586 this_instance
->ServiceNames
= NULL
;
588 /* isolate CBF flags in one go, expect this will go the way of all attempts to be clever !! */
590 this_instance
->CBF_Flags
=afCmd
^((afCmd
&MF_MASK
)|((afCmd
&APPCMD_MASK
)|(afCmd
&APPCLASS_MASK
)));
592 if ( ! this_instance
->Client_only
)
595 /* Check for other way of setting Client-only !! */
597 this_instance
->Client_only
=(this_instance
->CBF_Flags
&CBF_FAIL_ALLSVRXACTIONS
)
598 ==CBF_FAIL_ALLSVRXACTIONS
;
601 TRACE("instance created - checking validity \n");
603 if( *pidInst
== 0 ) {
604 /* Initialisation of new Instance Identifier */
605 TRACE("new instance, callback %p flags %lX\n",pfnCallback
,afCmd
);
606 if ( DDE_Max_Assigned_Instance
== 0 )
608 /* Nothing has been initialised - exit now ! can return TRUE since effect is the same */
609 /* Need to set up Mutex in case it is not already present */
610 s_att
->bInheritHandle
= TRUE
;
611 s_att
->lpSecurityDescriptor
= NULL
;
612 s_att
->nLength
= sizeof(s_att
);
613 handle_mutex
= CreateMutexA(s_att
,1,DDEHandleAccess
);
614 handle_mutex
= ConvertToGlobalHandle(handle_mutex
); /* fixme when having seperate adresspaces*/
615 if ( !handle_mutex
) {
616 ERR("CreateMutex failed - handle list %li\n",GetLastError());
617 HeapFree(SystemHeap
, 0, this_instance
);
618 return DMLERR_SYS_ERROR
;
621 if ( !WaitForMutex(handle_mutex
) )
623 return DMLERR_SYS_ERROR
;
627 TRACE("Handle Mutex created/reserved\n");
628 if (DDE_Handle_Table_Base
== NULL
)
630 /* can't be another instance in this case, assign to the base pointer */
631 DDE_Handle_Table_Base
= this_instance
;
633 /* since first must force filter of XTYP_CONNECT and XTYP_WILDCONNECT for
635 * ------------------------------- NOTE NOTE NOTE --------------------------
637 * the manual is not clear if this condition
638 * applies to the first call to DdeInitialize from an application, or the
639 * first call for a given callback !!!
642 this_instance
->CBF_Flags
=this_instance
->CBF_Flags
|APPCMD_FILTERINITS
;
643 TRACE("First application instance detected OK\n");
644 /* allocate new instance ID */
645 if ((err_no
= IncrementInstanceId( this_instance
)) ) return err_no
;
648 /* really need to chain the new one in to the latest here, but after checking conditions
649 * such as trying to start a conversation from an application trying to monitor */
650 reference_inst
= DDE_Handle_Table_Base
;
651 TRACE("Subsequent application instance - starting checks\n");
652 while ( reference_inst
->Next_Entry
!= NULL
)
655 * This set of tests will work if application uses same instance Id
656 * at application level once allocated - which is what manual implies
657 * should happen. If someone tries to be
658 * clever (lazy ?) it will fail to pick up that later calls are for
659 * the same application - should we trust them ?
661 if ( this_instance
->Instance_id
== reference_inst
->Instance_id
)
663 /* Check 1 - must be same Client-only state */
665 if ( this_instance
->Client_only
!= reference_inst
->Client_only
)
667 if ( Release_reserved_mutex(handle_mutex
,"handle_mutex",0,1,this_instance
))
668 return DMLERR_SYS_ERROR
;
669 return DMLERR_DLL_USAGE
;
672 /* Check 2 - cannot use 'Monitor' with any non-monitor modes */
674 if ( this_instance
->Monitor
!= reference_inst
->Monitor
)
676 if ( Release_reserved_mutex(handle_mutex
,"handle_mutex",0,1,this_instance
))
677 return DMLERR_SYS_ERROR
;
678 return DMLERR_INVALIDPARAMETER
;
681 /* Check 3 - must supply different callback address */
683 if ( this_instance
->CallBack
== reference_inst
->CallBack
)
685 if ( Release_reserved_mutex(handle_mutex
,"handle_mutex",0,1,this_instance
))
686 return DMLERR_SYS_ERROR
;
687 return DMLERR_DLL_USAGE
;
690 reference_inst
= reference_inst
->Next_Entry
;
692 /* All cleared, add to chain */
694 TRACE("Application Instance checks finished\n");
695 if ((err_no
= IncrementInstanceId( this_instance
)) ) return err_no
;
696 if ( Release_reserved_mutex(handle_mutex
,"handle_mutex",0,0,this_instance
)) return DMLERR_SYS_ERROR
;
697 reference_inst
->Next_Entry
= this_instance
;
699 *pidInst
= this_instance
->Instance_id
;
700 TRACE("New application instance processing finished OK\n");
702 /* Reinitialisation situation --- FIX */
703 TRACE("reinitialisation of (%p,%p,0x%lx,%ld): stub\n",pidInst
,pfnCallback
,afCmd
,ulRes
);
705 if ( !WaitForMutex(handle_mutex
) )
707 HeapFree(SystemHeap
, 0, this_instance
);
708 return DMLERR_SYS_ERROR
;
711 if (DDE_Handle_Table_Base
== NULL
)
713 if ( Release_reserved_mutex(handle_mutex
,"handle_mutex",0,1,this_instance
)) return DMLERR_SYS_ERROR
;
714 return DMLERR_DLL_USAGE
;
716 HeapFree(SystemHeap
, 0, this_instance
); /* finished - release heap space used as work store */
717 /* can't reinitialise if we have initialised nothing !! */
718 reference_inst
= DDE_Handle_Table_Base
;
719 /* must first check if we have been given a valid instance to re-initialise !! how do we do that ? */
721 * MS allows initialisation without specifying a callback, should we allow addition of the
722 * callback by a later call to initialise ? - if so this lot will have to change
724 while ( reference_inst
->Next_Entry
!= NULL
)
726 if ( *pidInst
== reference_inst
->Instance_id
&& pfnCallback
== reference_inst
->CallBack
)
728 /* Check 1 - cannot change client-only mode if set via APPCMD_CLIENTONLY */
730 if ( reference_inst
->Client_only
)
732 if ((reference_inst
->CBF_Flags
& CBF_FAIL_ALLSVRXACTIONS
) != CBF_FAIL_ALLSVRXACTIONS
)
734 /* i.e. Was set to Client-only and through APPCMD_CLIENTONLY */
736 if ( ! ( afCmd
& APPCMD_CLIENTONLY
))
738 if ( Release_reserved_mutex(handle_mutex
,"handle_mutex",0,1,this_instance
))
739 return DMLERR_SYS_ERROR
;
740 return DMLERR_DLL_USAGE
;
744 /* Check 2 - cannot change monitor modes */
746 if ( this_instance
->Monitor
!= reference_inst
->Monitor
)
748 if ( Release_reserved_mutex(handle_mutex
,"handle_mutex",0,1,this_instance
))
749 return DMLERR_SYS_ERROR
;
750 return DMLERR_DLL_USAGE
;
753 /* Check 3 - trying to set Client-only via APPCMD when not set so previously */
755 if (( afCmd
&APPCMD_CLIENTONLY
) && ! reference_inst
->Client_only
)
757 if ( Release_reserved_mutex(handle_mutex
,"handle_mutex",0,1,this_instance
))
758 return DMLERR_SYS_ERROR
;
759 return DMLERR_DLL_USAGE
;
763 reference_inst
= reference_inst
->Next_Entry
;
765 if ( reference_inst
->Next_Entry
== NULL
)
767 /* Crazy situation - trying to re-initialize something that has not beeen initialized !!
769 * Manual does not say what we do, cannot return DMLERR_NOT_INITIALIZED so what ?
771 if ( Release_reserved_mutex(handle_mutex
,"handle_mutex",0,1,this_instance
))
772 return DMLERR_SYS_ERROR
;
773 return DMLERR_INVALIDPARAMETER
;
775 /* All checked - change relevant flags */
777 reference_inst
->CBF_Flags
= this_instance
->CBF_Flags
;
778 reference_inst
->Client_only
= this_instance
->Client_only
;
779 reference_inst
->Monitor_flags
= this_instance
->Monitor_flags
;
780 if ( Release_reserved_mutex(handle_mutex
,"handle_mutex",0,1,this_instance
))
781 return DMLERR_SYS_ERROR
;
784 return DMLERR_NO_ERROR
;
788 /*****************************************************************
789 * DdeUninitialize16 (DDEML.3)
791 BOOL16 WINAPI
DdeUninitialize16( DWORD idInst
)
793 FIXME(" stub calling DdeUninitialize\n");
794 return (BOOL16
)DdeUninitialize( idInst
);
798 /*****************************************************************
799 * DdeUninitialize [USER32.119] Frees DDEML resources
802 * idInst [I] Instance identifier
809 BOOL WINAPI
DdeUninitialize( DWORD idInst
)
811 /* Stage one - check if we have a handle for this instance
813 SECURITY_ATTRIBUTES
*s_att
= NULL
;
814 SECURITY_ATTRIBUTES s_attrib
;
815 DDE_HANDLE_ENTRY
*this_instance
;
816 DDE_HANDLE_ENTRY
*reference_inst
;
819 if ( DDE_Max_Assigned_Instance
== 0 )
821 /* Nothing has been initialised - exit now ! can return TRUE since effect is the same */
825 if ( !WaitForMutex(handle_mutex
) )
827 return DMLERR_SYS_ERROR
;
829 TRACE("Handle Mutex created/reserved\n");
830 /* First check instance
832 this_instance
= Find_Instance_Entry(idInst
);
833 if ( this_instance
== NULL
)
835 if ( Release_reserved_mutex(handle_mutex
,"handle_mutex",FALSE
,FALSE
,this_instance
)) return FALSE
;
837 * Needs something here to record NOT_INITIALIZED ready for DdeGetLastError
841 FIXME("(%ld): partial stub\n", idInst
);
843 /* FIXME ++++++++++++++++++++++++++++++++++++++++++
844 * Needs to de-register all service names
847 /* Free the nodes that were not freed by this instance
848 * and remove the nodes from the list of HSZ nodes.
850 FreeAndRemoveHSZNodes( idInst
, this_instance
);
852 /* OK now delete the instance handle itself */
854 if ( DDE_Handle_Table_Base
== this_instance
)
856 /* special case - the first/only entry
858 DDE_Handle_Table_Base
= this_instance
->Next_Entry
;
863 reference_inst
= DDE_Handle_Table_Base
;
864 while ( reference_inst
->Next_Entry
!= this_instance
)
866 reference_inst
= this_instance
->Next_Entry
;
868 reference_inst
->Next_Entry
= this_instance
->Next_Entry
;
870 /* release the mutex and the heap entry
872 if ( Release_reserved_mutex(handle_mutex
,"handle_mutex",FALSE
,TRUE
,this_instance
))
874 /* should record something here, but nothing left to hang it from !!
882 /*****************************************************************
883 * DdeConnectList16 [DDEML.4]
886 HCONVLIST WINAPI
DdeConnectList16( DWORD idInst
, HSZ hszService
, HSZ hszTopic
,
887 HCONVLIST hConvList
, LPCONVCONTEXT16 pCC
)
889 return DdeConnectList(idInst
, hszService
, hszTopic
, hConvList
,
894 /******************************************************************************
895 * DdeConnectList [USER32.93] Establishes conversation with DDE servers
898 * idInst [I] Instance identifier
899 * hszService [I] Handle to service name string
900 * hszTopic [I] Handle to topic name string
901 * hConvList [I] Handle to conversation list
902 * pCC [I] Pointer to structure with context data
905 * Success: Handle to new conversation list
908 HCONVLIST WINAPI
DdeConnectList( DWORD idInst
, HSZ hszService
, HSZ hszTopic
,
909 HCONVLIST hConvList
, LPCONVCONTEXT pCC
)
911 FIXME("(%ld,%ld,%ld,%ld,%p): stub\n", idInst
, hszService
, hszTopic
,
917 /*****************************************************************
918 * DdeQueryNextServer16 [DDEML.5]
920 HCONV WINAPI
DdeQueryNextServer16( HCONVLIST hConvList
, HCONV hConvPrev
)
922 return DdeQueryNextServer(hConvList
, hConvPrev
);
926 /*****************************************************************
927 * DdeQueryNextServer [USER32.112]
929 HCONV WINAPI
DdeQueryNextServer( HCONVLIST hConvList
, HCONV hConvPrev
)
931 FIXME("(%ld,%ld): stub\n",hConvList
,hConvPrev
);
935 /*****************************************************************
936 * DdeQueryStringA [USER32.113]
938 *****************************************************************
942 * Vn Date Author Comment
944 * 1.0 Dec 1998 Corel/Macadamian Initial version
945 * 1.1 Mar 1999 Keith Matthews Added links to instance table and related processing
948 DWORD WINAPI
DdeQueryStringA(DWORD idInst
, HSZ hsz
, LPSTR psz
, DWORD cchMax
, INT iCodePage
)
951 CHAR pString
[MAX_BUFFER_LEN
];
952 DDE_HANDLE_ENTRY
*reference_inst
;
955 "(%ld, 0x%lx, %p, %ld, %d): partial stub\n",
961 if ( DDE_Max_Assigned_Instance
== 0 )
963 /* Nothing has been initialised - exit now ! */
964 /* needs something for DdeGetLAstError even if the manual doesn't say so */
968 if ( !WaitForMutex(handle_mutex
) )
973 TRACE("Handle Mutex created/reserved\n");
975 /* First check instance
977 reference_inst
= Find_Instance_Entry(idInst
);
978 if ( reference_inst
== NULL
)
980 if ( Release_reserved_mutex(handle_mutex
,"handle_mutex",FALSE
,FALSE
,reference_inst
)) return FALSE
;
982 Needs something here to record NOT_INITIALIZED ready for DdeGetLastError
987 if( iCodePage
== CP_WINANSI
)
989 /* If psz is null, we have to return only the length
995 cchMax
= MAX_BUFFER_LEN
;
998 ret
= GlobalGetAtomNameA( hsz
, (LPSTR
)psz
, cchMax
);
1000 Release_reserved_mutex(handle_mutex
,"handle_mutex",FALSE
,FALSE
,reference_inst
);
1002 TRACE("returning pointer\n");
1006 /*****************************************************************
1007 * DdeQueryStringW [USER32.114]
1009 *****************************************************************
1013 * Vn Date Author Comment
1015 * 1.0 Dec 1998 Corel/Macadamian Initial version
1019 DWORD WINAPI
DdeQueryStringW(DWORD idInst
, HSZ hsz
, LPWSTR psz
, DWORD cchMax
, INT iCodePage
)
1022 WCHAR pString
[MAX_BUFFER_LEN
];
1026 "(%ld, 0x%lx, %p, %ld, %d): stub\n",
1033 if( iCodePage
== CP_WINUNICODE
)
1035 /* If psz is null, we have to return only the length
1041 cchMax
= MAX_BUFFER_LEN
;
1042 /* Note: According to documentation if the psz parameter
1043 * was NULL this API must return the length of the string in bytes.
1045 factor
= (int) sizeof(WCHAR
)/sizeof(BYTE
);
1047 ret
= GlobalGetAtomNameW( hsz
, (LPWSTR
)psz
, cchMax
) * factor
;
1052 /*****************************************************************
1054 * DdeQueryString16 (DDEML.23)
1056 ******************************************************************
1060 * Vn Date Author Comment
1062 * 1.0 March 1999 K Matthews stub only
1065 DWORD WINAPI
DdeQueryString16(DWORD idInst
, HSZ hsz
, LPSTR lpsz
, DWORD cchMax
, int codepage
)
1067 FIXME("(%ld, 0x%lx, %p, %ld, %d): stub \n",
1077 /*****************************************************************
1078 * DdeDisconnectList (DDEML.6)
1080 BOOL16 WINAPI
DdeDisconnectList16( HCONVLIST hConvList
)
1082 return (BOOL16
)DdeDisconnectList(hConvList
);
1086 /******************************************************************************
1087 * DdeDisconnectList [USER32.98] Destroys list and terminates conversations
1093 BOOL WINAPI
DdeDisconnectList(
1094 HCONVLIST hConvList
) /* [in] Handle to conversation list */
1096 FIXME("(%ld): stub\n", hConvList
);
1101 /*****************************************************************
1102 * DdeConnect16 (DDEML.7)
1104 HCONV WINAPI
DdeConnect16( DWORD idInst
, HSZ hszService
, HSZ hszTopic
,
1105 LPCONVCONTEXT16 pCC
)
1107 FIXME("empty stub\n" );
1112 /*****************************************************************
1113 * DdeConnect (USER32.92)
1115 HCONV WINAPI
DdeConnect( DWORD idInst
, HSZ hszService
, HSZ hszTopic
,
1118 FIXME("(0x%lx,%ld,%ld,%p): stub\n",idInst
,hszService
,hszTopic
,
1124 /*****************************************************************
1125 * DdeDisconnect16 (DDEML.8)
1127 BOOL16 WINAPI
DdeDisconnect16( HCONV hConv
)
1129 return (BOOL16
)DdeDisconnect( hConv
);
1132 /*****************************************************************
1133 * DdeSetUserHandle16 (DDEML.10)
1135 BOOL16 WINAPI
DdeSetUserHandle16( HCONV hConv
, DWORD id
, DWORD hUser
)
1137 FIXME("(%ld,%ld,%ld): stub\n",hConv
,id
, hUser
);
1141 /*****************************************************************
1142 * DdeCreateDataHandle16 (DDEML.14)
1144 HDDEDATA WINAPI
DdeCreateDataHandle16( DWORD idInst
, LPBYTE pSrc
, DWORD cb
,
1145 DWORD cbOff
, HSZ hszItem
, UINT16 wFmt
,
1148 return DdeCreateDataHandle(idInst
,
1157 /*****************************************************************
1158 * DdeCreateDataHandle (USER32.94)
1160 HDDEDATA WINAPI
DdeCreateDataHandle( DWORD idInst
, LPBYTE pSrc
, DWORD cb
,
1161 DWORD cbOff
, HSZ hszItem
, UINT wFmt
,
1165 "(%ld,%p,%ld,%ld,0x%lx,%d,%d): stub\n",
1177 /*****************************************************************
1178 * DdeDisconnect (USER32.97)
1180 BOOL WINAPI
DdeDisconnect( HCONV hConv
)
1182 FIXME("empty stub\n" );
1187 /*****************************************************************
1188 * DdeReconnect (DDEML.37) (USER32.115)
1190 HCONV WINAPI
DdeReconnect( HCONV hConv
)
1192 FIXME("empty stub\n" );
1197 /*****************************************************************
1198 * DdeCreateStringHandle16 (DDEML.21)
1200 *****************************************************************
1204 * Vn Date Author Comment
1206 * 1.0 ? ? basic stub
1207 * 1.1 June 1999 Keith Matthews amended onward call to supply default
1208 * code page if none supplied by caller
1210 HSZ WINAPI
DdeCreateStringHandle16( DWORD idInst
, LPCSTR str
, INT16 codepage
)
1214 return DdeCreateStringHandleA( idInst
, str
, codepage
);
1216 TRACE("Default codepage supplied\n");
1217 return DdeCreateStringHandleA( idInst
, str
, CP_WINANSI
);
1222 /*****************************************************************
1223 * DdeCreateStringHandleA [USER32.95]
1226 * Success: String handle
1229 *****************************************************************
1233 * Vn Date Author Comment
1235 * 1.0 Dec 1998 Corel/Macadamian Initial version
1236 * 1.1 Mar 1999 Keith Matthews Added links to instance table and related processing
1239 HSZ WINAPI
DdeCreateStringHandleA( DWORD idInst
, LPCSTR psz
, INT codepage
)
1242 DDE_HANDLE_ENTRY
*reference_inst
;
1243 TRACE("(%ld,%s,%d): partial stub\n",idInst
,debugstr_a(psz
),codepage
);
1246 if ( DDE_Max_Assigned_Instance
== 0 )
1248 /* Nothing has been initialised - exit now ! can return FALSE since effect is the same */
1252 if ( !WaitForMutex(handle_mutex
) )
1254 return DMLERR_SYS_ERROR
;
1257 TRACE("Handle Mutex created/reserved\n");
1259 /* First check instance
1261 reference_inst
= Find_Instance_Entry(idInst
);
1262 if ( reference_inst
== NULL
)
1264 if ( Release_reserved_mutex(handle_mutex
,"handle_mutex",FALSE
,FALSE
,reference_inst
)) return 0;
1266 Needs something here to record NOT_INITIALIZED ready for DdeGetLastError
1271 if (codepage
==CP_WINANSI
)
1273 hsz
= GlobalAddAtomA (psz
);
1274 /* Save the handle so we know to clean it when
1275 * uninitialize is called.
1277 TRACE("added atom %s with HSZ 0x%lx, \n",debugstr_a(psz
),hsz
);
1278 InsertHSZNode( hsz
, reference_inst
);
1279 if ( Release_reserved_mutex(handle_mutex
,"handle_mutex",FALSE
,FALSE
,reference_inst
))
1281 reference_inst
->Last_Error
= DMLERR_SYS_ERROR
;
1284 TRACE("Returning pointer\n");
1287 Release_reserved_mutex(handle_mutex
,"handle_mutex",FALSE
,FALSE
,reference_inst
);
1289 TRACE("Returning error\n");
1294 /******************************************************************************
1295 * DdeCreateStringHandleW [USER32.96] Creates handle to identify string
1298 * Success: String handle
1301 *****************************************************************
1305 * Vn Date Author Comment
1307 * 1.0 Dec 1998 Corel/Macadamian Initial version
1308 * 1.1 Mar 1999 Keith Matthews Added links to instance table and related processing
1311 HSZ WINAPI
DdeCreateStringHandleW(
1312 DWORD idInst
, /* [in] Instance identifier */
1313 LPCWSTR psz
, /* [in] Pointer to string */
1314 INT codepage
) /* [in] Code page identifier */
1316 DDE_HANDLE_ENTRY
*reference_inst
;
1319 TRACE("(%ld,%s,%d): partial stub\n",idInst
,debugstr_w(psz
),codepage
);
1322 if ( DDE_Max_Assigned_Instance
== 0 )
1324 /* Nothing has been initialised - exit now ! can return FALSE since effect is the same */
1328 if ( !WaitForMutex(handle_mutex
) )
1330 return DMLERR_SYS_ERROR
;
1333 TRACE("CreateString - Handle Mutex created/reserved\n");
1335 /* First check instance
1337 reference_inst
= Find_Instance_Entry(idInst
);
1338 if ( reference_inst
== NULL
)
1340 if ( Release_reserved_mutex(handle_mutex
,"handle_mutex",FALSE
,FALSE
,reference_inst
)) return 0;
1342 Needs something here to record NOT_INITIALIZED ready for DdeGetLastError
1347 FIXME("(%ld,%s,%d): partial stub\n",idInst
,debugstr_w(psz
),codepage
);
1349 if (codepage
==CP_WINUNICODE
)
1351 Should we be checking this against the unicode/ascii nature of the call to DdeInitialize ?
1354 hsz
= GlobalAddAtomW (psz
);
1355 /* Save the handle so we know to clean it when
1356 * uninitialize is called.
1358 InsertHSZNode( hsz
, reference_inst
);
1359 if ( Release_reserved_mutex(handle_mutex
,"handle_mutex",FALSE
,FALSE
,reference_inst
))
1361 reference_inst
->Last_Error
= DMLERR_SYS_ERROR
;
1364 TRACE("Returning pointer\n");
1367 Release_reserved_mutex(handle_mutex
,"handle_mutex",FALSE
,FALSE
,reference_inst
);
1369 TRACE("Returning error\n");
1374 /*****************************************************************
1375 * DdeFreeStringHandle16 (DDEML.22)
1377 BOOL16 WINAPI
DdeFreeStringHandle16( DWORD idInst
, HSZ hsz
)
1379 FIXME("idInst %ld hsz 0x%lx\n",idInst
,hsz
);
1380 return (BOOL
)DdeFreeStringHandle( idInst
, hsz
);
1384 /*****************************************************************
1385 * DdeFreeStringHandle (USER32.101)
1386 * RETURNS: success: nonzero
1389 *****************************************************************
1393 * Vn Date Author Comment
1395 * 1.0 Dec 1998 Corel/Macadamian Initial version
1396 * 1.1 Apr 1999 Keith Matthews Added links to instance table and related processing
1399 BOOL WINAPI
DdeFreeStringHandle( DWORD idInst
, HSZ hsz
)
1401 DDE_HANDLE_ENTRY
*reference_inst
;
1402 TRACE("(%ld,%ld): \n",idInst
,hsz
);
1403 if ( DDE_Max_Assigned_Instance
== 0 )
1405 /* Nothing has been initialised - exit now ! can return TRUE since effect is the same */
1409 if ( !WaitForMutex(handle_mutex
) )
1411 return DMLERR_SYS_ERROR
;
1414 TRACE("Handle Mutex created/reserved\n");
1416 /* First check instance
1418 reference_inst
= Find_Instance_Entry(idInst
);
1419 if ( (reference_inst
== NULL
) || (reference_inst
->Node_list
== NULL
))
1421 if ( Release_reserved_mutex(handle_mutex
,"handle_mutex",FALSE
,FALSE
,reference_inst
)) return TRUE
;
1422 /* Nothing has been initialised - exit now ! can return TRUE since effect is the same */
1427 /* Remove the node associated with this HSZ.
1429 RemoveHSZNode( hsz
, reference_inst
);
1430 /* Free the string associated with this HSZ.
1432 Release_reserved_mutex(handle_mutex
,"handle_mutex",FALSE
,FALSE
,reference_inst
);
1433 return GlobalDeleteAtom (hsz
) ? 0 : hsz
;
1437 /*****************************************************************
1438 * DdeFreeDataHandle16 (DDEML.19)
1440 BOOL16 WINAPI
DdeFreeDataHandle16( HDDEDATA hData
)
1442 return (BOOL
)DdeFreeDataHandle( hData
);
1446 /*****************************************************************
1447 * DdeFreeDataHandle (USER32.100)
1449 BOOL WINAPI
DdeFreeDataHandle( HDDEDATA hData
)
1451 FIXME("empty stub\n" );
1458 /*****************************************************************
1459 * DdeKeepStringHandle16 (DDEML.24)
1461 BOOL16 WINAPI
DdeKeepStringHandle16( DWORD idInst
, HSZ hsz
)
1463 return (BOOL
)DdeKeepStringHandle( idInst
, hsz
);
1467 /*****************************************************************
1468 * DdeKeepStringHandle (USER32.108)
1470 * RETURNS: success: nonzero
1473 *****************************************************************
1477 * Vn Date Author Comment
1480 * 1.1 Jun 1999 Keith Matthews First cut implementation
1483 BOOL WINAPI
DdeKeepStringHandle( DWORD idInst
, HSZ hsz
)
1486 DDE_HANDLE_ENTRY
*reference_inst
;
1487 TRACE("(%ld,%ld): \n",idInst
,hsz
);
1488 if ( DDE_Max_Assigned_Instance
== 0 )
1490 /* Nothing has been initialised - exit now ! can return FALSE since effect is the same */
1495 if ( !WaitForMutex(handle_mutex
) )
1500 TRACE("Handle Mutex created/reserved\n");
1502 /* First check instance
1504 reference_inst
= Find_Instance_Entry(idInst
);
1505 if ( (reference_inst
== NULL
) || (reference_inst
->Node_list
== NULL
))
1507 if ( Release_reserved_mutex(handle_mutex
,"handle_mutex",FALSE
,FALSE
,reference_inst
)) return FALSE
;
1508 /* Nothing has been initialised - exit now ! can return FALSE since effect is the same */
1512 DdeReserveAtom(reference_inst
,hsz
);
1513 Release_reserved_mutex(handle_mutex
,"handle_mutex",FALSE
,FALSE
,reference_inst
);
1518 /*****************************************************************
1519 * DdeClientTransaction16 (DDEML.11)
1521 HDDEDATA WINAPI
DdeClientTransaction16( LPVOID pData
, DWORD cbData
,
1522 HCONV hConv
, HSZ hszItem
, UINT16 wFmt
,
1523 UINT16 wType
, DWORD dwTimeout
,
1526 return DdeClientTransaction( (LPBYTE
)pData
, cbData
, hConv
, hszItem
,
1527 wFmt
, wType
, dwTimeout
, pdwResult
);
1531 /*****************************************************************
1532 * DdeClientTransaction (USER32.90)
1534 HDDEDATA WINAPI
DdeClientTransaction( LPBYTE pData
, DWORD cbData
,
1535 HCONV hConv
, HSZ hszItem
, UINT wFmt
,
1536 UINT wType
, DWORD dwTimeout
,
1539 FIXME("empty stub\n" );
1543 /*****************************************************************
1545 * DdeAbandonTransaction16 (DDEML.12)
1548 BOOL16 WINAPI
DdeAbandonTransaction16( DWORD idInst
, HCONV hConv
,
1549 DWORD idTransaction
)
1551 FIXME("empty stub\n" );
1556 /*****************************************************************
1558 * DdeAbandonTransaction (USER32.87)
1560 ******************************************************************
1564 * Vn Date Author Comment
1566 * 1.0 March 1999 K Matthews stub only
1568 BOOL WINAPI
DdeAbandonTransaction( DWORD idInst
, HCONV hConv
,
1569 DWORD idTransaction
)
1571 FIXME("empty stub\n" );
1575 /*****************************************************************
1576 * DdePostAdvise16 [DDEML.13]
1578 BOOL16 WINAPI
DdePostAdvise16( DWORD idInst
, HSZ hszTopic
, HSZ hszItem
)
1580 return (BOOL16
)DdePostAdvise(idInst
, hszTopic
, hszItem
);
1584 /******************************************************************************
1585 * DdePostAdvise [USER32.110] Send transaction to DDE callback function.
1591 BOOL WINAPI
DdePostAdvise(
1592 DWORD idInst
, /* [in] Instance identifier */
1593 HSZ hszTopic
, /* [in] Handle to topic name string */
1594 HSZ hszItem
) /* [in] Handle to item name string */
1596 FIXME("(%ld,%ld,%ld): stub\n",idInst
,hszTopic
,hszItem
);
1601 /*****************************************************************
1602 * DdeAddData16 (DDEML.15)
1604 HDDEDATA WINAPI
DdeAddData16( HDDEDATA hData
, LPBYTE pSrc
, DWORD cb
,
1607 FIXME("empty stub\n" );
1611 /*****************************************************************
1613 * DdeAddData (USER32.89)
1615 ******************************************************************
1619 * Vn Date Author Comment
1621 * 1.0 March 1999 K Matthews stub only
1623 HDDEDATA WINAPI
DdeAddData( HDDEDATA hData
, LPBYTE pSrc
, DWORD cb
,
1626 FIXME("empty stub\n" );
1631 /*****************************************************************
1633 * DdeImpersonateClient (USER32.105)
1635 ******************************************************************
1639 * Vn Date Author Comment
1641 * 1.0 March 1999 K Matthews stub only
1644 BOOL WINAPI
DdeImpersonateClient( HCONV hConv
)
1646 FIXME("empty stub\n" );
1651 /*****************************************************************
1653 * DdeSetQualityOfService (USER32.116)
1655 ******************************************************************
1659 * Vn Date Author Comment
1661 * 1.0 March 1999 K Matthews stub only
1664 BOOL WINAPI
DdeSetQualityOfService( HWND hwndClient
, CONST SECURITY_QUALITY_OF_SERVICE
*pqosNew
,
1665 PSECURITY_QUALITY_OF_SERVICE pqosPrev
)
1667 FIXME("empty stub\n" );
1671 /*****************************************************************
1673 * DdeSetUserHandle (USER32.117)
1675 ******************************************************************
1679 * Vn Date Author Comment
1681 * 1.0 March 1999 K Matthews stub only
1684 BOOL WINAPI
DdeSetUserHandle( HCONV hConv
, DWORD id
, DWORD hUser
)
1686 FIXME("empty stub\n" );
1690 /******************************************************************************
1691 * DdeGetData [USER32.102] Copies data from DDE object ot local buffer
1694 * Size of memory object associated with handle
1696 DWORD WINAPI
DdeGetData(
1697 HDDEDATA hData
, /* [in] Handle to DDE object */
1698 LPBYTE pDst
, /* [in] Pointer to destination buffer */
1699 DWORD cbMax
, /* [in] Amount of data to copy */
1700 DWORD cbOff
) /* [in] Offset to beginning of data */
1702 FIXME("(%ld,%p,%ld,%ld): stub\n",hData
,pDst
,cbMax
,cbOff
);
1707 /*****************************************************************
1708 * DdeGetData16 [DDEML.16]
1710 DWORD WINAPI
DdeGetData16(
1716 return DdeGetData(hData
, pDst
, cbMax
, cbOff
);
1720 /*****************************************************************
1721 * DdeAccessData16 (DDEML.17)
1723 LPBYTE WINAPI
DdeAccessData16( HDDEDATA hData
, LPDWORD pcbDataSize
)
1725 return DdeAccessData(hData
, pcbDataSize
);
1728 /*****************************************************************
1729 * DdeAccessData (USER32.88)
1731 LPBYTE WINAPI
DdeAccessData( HDDEDATA hData
, LPDWORD pcbDataSize
)
1733 FIXME("(%ld,%p): stub\n", hData
, pcbDataSize
);
1737 /*****************************************************************
1738 * DdeUnaccessData16 (DDEML.18)
1740 BOOL16 WINAPI
DdeUnaccessData16( HDDEDATA hData
)
1742 return DdeUnaccessData(hData
);
1745 /*****************************************************************
1746 * DdeUnaccessData (USER32.118)
1748 BOOL WINAPI
DdeUnaccessData( HDDEDATA hData
)
1750 FIXME("(0x%lx): stub\n", hData
);
1755 /*****************************************************************
1756 * DdeEnableCallback16 (DDEML.26)
1758 BOOL16 WINAPI
DdeEnableCallback16( DWORD idInst
, HCONV hConv
, UINT16 wCmd
)
1760 return DdeEnableCallback(idInst
, hConv
, wCmd
);
1763 /*****************************************************************
1764 * DdeEnableCallback (USER32.99)
1766 BOOL WINAPI
DdeEnableCallback( DWORD idInst
, HCONV hConv
, UINT wCmd
)
1768 FIXME("(%ld, 0x%lx, %d) stub\n", idInst
, hConv
, wCmd
);
1773 /*****************************************************************
1774 * DdeNameService16 (DDEML.27)
1776 HDDEDATA WINAPI
DdeNameService16( DWORD idInst
, HSZ hsz1
, HSZ hsz2
,
1779 return DdeNameService( idInst
, hsz1
, hsz2
, afCmd
);
1783 /******************************************************************************
1784 * DdeNameService [USER32.109] {Un}registers service name of DDE server
1787 * idInst [I] Instance identifier
1788 * hsz1 [I] Handle to service name string
1790 * afCmd [I] Service name flags
1796 *****************************************************************
1800 * Vn Date Author Comment
1803 * 1.1 Apr 1999 Keith Matthews Added trap for non-existent instance (uninitialised instance 0
1804 * used by some MS programs for unfathomable reasons)
1805 * 1.2 May 1999 Keith Matthews Added parameter validation and basic service name handling.
1806 * Still needs callback parts
1809 HDDEDATA WINAPI
DdeNameService( DWORD idInst
, HSZ hsz1
, HSZ hsz2
,
1812 ServiceNode
* this_service
, *reference_service
;
1813 DDE_HANDLE_ENTRY
*this_instance
;
1814 DDE_HANDLE_ENTRY
*reference_inst
;
1815 this_service
= NULL
;
1817 FIXME("(%ld,%ld,%ld,%d): stub\n",idInst
,hsz1
,hsz2
,afCmd
);
1819 if ( DDE_Max_Assigned_Instance
== 0 )
1821 /* Nothing has been initialised - exit now !
1822 * needs something for DdeGetLastError */
1826 if ( !WaitForMutex(handle_mutex
) )
1828 return DMLERR_SYS_ERROR
;
1831 TRACE("Handle Mutex created/reserved\n");
1833 /* First check instance
1835 reference_inst
= Find_Instance_Entry(idInst
);
1836 this_instance
= reference_inst
;
1837 if (reference_inst
== NULL
)
1839 TRACE("Instance not found as initialised\n");
1840 if ( Release_reserved_mutex(handle_mutex
,"handle_mutex",FALSE
,FALSE
,this_instance
)) return TRUE
;
1841 /* Nothing has been initialised - exit now ! can return TRUE since effect is the same */
1848 /* Illegal, reserved parameter
1850 reference_inst
->Last_Error
= DMLERR_INVALIDPARAMETER
;
1851 Release_reserved_mutex(handle_mutex
,"handle_mutex",FALSE
,FALSE
,this_instance
);
1852 FIXME("Reserved parameter no-zero !!\n");
1858 * General unregister situation
1860 if ( afCmd
!= DNS_UNREGISTER
)
1862 /* don't know if we should check this but it makes sense
1863 * why supply REGISTER or filter flags if de-registering all
1865 TRACE("General unregister unexpected flags\n");
1866 reference_inst
->Last_Error
= DMLERR_DLL_USAGE
;
1867 Release_reserved_mutex(handle_mutex
,"handle_mutex",FALSE
,FALSE
,this_instance
);
1870 /* Loop to find all registered service and de-register them
1872 if ( reference_inst
->ServiceNames
== NULL
)
1874 /* None to unregister !!
1876 TRACE("General de-register - nothing registered\n");
1877 reference_inst
->Last_Error
= DMLERR_DLL_USAGE
;
1878 Release_reserved_mutex(handle_mutex
,"handle_mutex",FALSE
,FALSE
,this_instance
);
1882 this_service
= reference_inst
->ServiceNames
;
1883 while ( this_service
->next
!= NULL
)
1885 TRACE("general deregister - iteration\n");
1886 reference_service
= this_service
;
1887 this_service
= this_service
->next
;
1888 DdeReleaseAtom(reference_inst
,reference_service
->hsz
);
1889 HeapFree(SystemHeap
, 0, reference_service
); /* finished - release heap space used as work store */
1891 DdeReleaseAtom(reference_inst
,this_service
->hsz
);
1892 HeapFree(SystemHeap
, 0, this_service
); /* finished - release heap space used as work store */
1893 reference_inst
->ServiceNames
= NULL
;
1894 TRACE("General de-register - finished\n");
1896 Release_reserved_mutex(handle_mutex
,"handle_mutex",FALSE
,FALSE
,this_instance
);
1899 TRACE("Specific name action detected\n");
1900 if ( afCmd
& DNS_REGISTER
)
1902 /* Register new service name
1905 this_service
= Find_Service_Name( hsz1
, reference_inst
);
1907 ERR("Trying to register already registered service!\n");
1910 TRACE("Adding service name\n");
1912 DdeReserveAtom(reference_inst
, hsz1
);
1914 this_service
= (ServiceNode
*)HeapAlloc( SystemHeap
, 0, sizeof(ServiceNode
) );
1915 this_service
->hsz
= hsz1
;
1916 this_service
->FilterOn
= TRUE
;
1918 this_service
->next
= reference_inst
->ServiceNames
;
1919 reference_inst
->ServiceNames
= this_service
;
1922 if ( afCmd
& DNS_UNREGISTER
)
1924 /* De-register service name
1927 ServiceNode
**pServiceNode
= &reference_inst
->ServiceNames
;
1928 while ( *pServiceNode
&& (*pServiceNode
)->hsz
!= hsz1
)
1929 pServiceNode
= &(*pServiceNode
)->next
;
1931 this_service
= *pServiceNode
;
1932 if ( !this_service
)
1933 ERR("Trying to de-register unregistered service!\n");
1936 *pServiceNode
= this_service
->next
;
1937 DdeReleaseAtom(reference_inst
,this_service
->hsz
);
1938 HeapFree(SystemHeap
, 0, this_service
);
1941 if ( afCmd
& DNS_FILTERON
)
1943 /* Set filter flags on to hold notifications of connection
1945 * test coded this way as this is the default setting
1947 this_service
= Find_Service_Name( hsz1
, reference_inst
);
1948 if ( !this_service
)
1950 /* trying to filter where no service names !!
1952 reference_inst
->Last_Error
= DMLERR_DLL_USAGE
;
1953 Release_reserved_mutex(handle_mutex
,"handle_mutex",FALSE
,FALSE
,this_instance
);
1957 this_service
->FilterOn
= TRUE
;
1960 if ( afCmd
& DNS_FILTEROFF
)
1962 /* Set filter flags on to hold notifications of connection
1964 this_service
= Find_Service_Name( hsz1
, reference_inst
);
1965 if ( !this_service
)
1967 /* trying to filter where no service names !!
1969 reference_inst
->Last_Error
= DMLERR_DLL_USAGE
;
1970 Release_reserved_mutex(handle_mutex
,"handle_mutex",FALSE
,FALSE
,this_instance
);
1974 this_service
->FilterOn
= FALSE
;
1977 Release_reserved_mutex(handle_mutex
,"handle_mutex",FALSE
,FALSE
,this_instance
);
1982 /*****************************************************************
1983 * DdeGetLastError16 (DDEML.20)
1985 UINT16 WINAPI
DdeGetLastError16( DWORD idInst
)
1987 return (UINT16
)DdeGetLastError( idInst
);
1991 /******************************************************************************
1992 * DdeGetLastError [USER32.103] Gets most recent error code
1995 * idInst [I] Instance identifier
2000 *****************************************************************
2004 * Vn Date Author Comment
2007 * 1.1 Apr 1999 Keith Matthews Added response for non-existent instance (uninitialised instance 0
2008 * used by some MS programs for unfathomable reasons)
2009 * 1.2 May 1999 Keith Matthews Added interrogation of Last_Error for instance handle where found.
2012 UINT WINAPI
DdeGetLastError( DWORD idInst
)
2015 DDE_HANDLE_ENTRY
*reference_inst
;
2017 FIXME("(%ld): stub\n",idInst
);
2019 if ( DDE_Max_Assigned_Instance
== 0 )
2021 /* Nothing has been initialised - exit now ! */
2022 return DMLERR_DLL_NOT_INITIALIZED
;
2025 if ( !WaitForMutex(handle_mutex
) )
2027 return DMLERR_SYS_ERROR
;
2030 TRACE("Handle Mutex created/reserved\n");
2032 /* First check instance
2034 reference_inst
= Find_Instance_Entry(idInst
);
2035 if (reference_inst
== NULL
)
2037 if ( Release_reserved_mutex(handle_mutex
,"handle_mutex",FALSE
,FALSE
,reference_inst
)) return TRUE
;
2038 /* Nothing has been initialised - exit now ! can return TRUE since effect is the same */
2039 return DMLERR_DLL_NOT_INITIALIZED
;
2042 error_code
= reference_inst
->Last_Error
;
2043 reference_inst
->Last_Error
= 0;
2044 Release_reserved_mutex(handle_mutex
,"handle_mutex",FALSE
,FALSE
,reference_inst
);
2049 /*****************************************************************
2050 * DdeCmpStringHandles16 (DDEML.36)
2052 int WINAPI
DdeCmpStringHandles16( HSZ hsz1
, HSZ hsz2
)
2054 return DdeCmpStringHandles(hsz1
, hsz2
);
2057 /*****************************************************************
2058 * DdeCmpStringHandles (USER32.91)
2060 * Compares the value of two string handles. This comparison is
2061 * not case sensitive.
2064 * -1 The value of hsz1 is zero or less than hsz2
2065 * 0 The values of hsz 1 and 2 are the same or both zero.
2066 * 1 The value of hsz2 is zero of less than hsz1
2068 int WINAPI
DdeCmpStringHandles( HSZ hsz1
, HSZ hsz2
)
2070 CHAR psz1
[MAX_BUFFER_LEN
];
2071 CHAR psz2
[MAX_BUFFER_LEN
];
2075 TRACE("handle 1, handle 2\n" );
2077 ret1
= GlobalGetAtomNameA( hsz1
, psz1
, MAX_BUFFER_LEN
);
2078 ret2
= GlobalGetAtomNameA( hsz2
, psz2
, MAX_BUFFER_LEN
);
2079 /* Make sure we found both strings.
2081 if( ret1
== 0 && ret2
== 0 )
2083 /* If both are not found, return both "zero strings".
2087 else if( ret1
== 0 )
2089 /* If hsz1 is a not found, return hsz1 is "zero string".
2093 else if( ret2
== 0 )
2095 /* If hsz2 is a not found, return hsz2 is "zero string".
2101 /* Compare the two strings we got ( case insensitive ).
2103 ret
= strcasecmp( psz1
, psz2
);
2104 /* Since strcmp returns any number smaller than
2105 * 0 when the first string is found to be less than
2106 * the second one we must make sure we are returning
2107 * the proper values.
2122 /*****************************************************************
2123 * PackDDElParam (USER32.414)
2129 UINT WINAPI
PackDDElParam(UINT msg
, UINT uiLo
, UINT uiHi
)
2136 /*****************************************************************
2137 * UnpackDDElParam (USER32.562)
2143 UINT WINAPI
UnpackDDElParam(UINT msg
, UINT lParam
,
2144 UINT
*uiLo
, UINT
*uiHi
)
2151 /*****************************************************************
2152 * FreeDDElParam (USER32.204)
2158 UINT WINAPI
FreeDDElParam(UINT msg
, UINT lParam
)
2164 /*****************************************************************
2165 * ReuseDDElParam (USER32.446)
2168 UINT WINAPI
ReuseDDElParam(UINT lParam
, UINT msgIn
, UINT msgOut
,
2169 UINT uiLi
, UINT uiHi
)
2175 /******************************************************************
2176 * DdeQueryConvInfo16 (DDEML.9)
2179 UINT16 WINAPI
DdeQueryConvInfo16( HCONV hconv
, DWORD idTransaction
, LPCONVINFO16 lpConvInfo
)
2186 /******************************************************************
2187 * DdeQueryConvInfo (USER32.111)
2190 UINT WINAPI
DdeQueryConvInfo( HCONV hconv
, DWORD idTransaction
, LPCONVINFO lpConvInfo
)