4 * Copyright 1997 Alexandre Julliard
5 * Copyright 1997 Len White
8 /* Only empty stubs for now */
17 /* FIXME: What are these values? */
18 #define DMLERR_NO_ERROR 0
20 /* Has defined in atom.c file.
22 #define MAX_ATOM_LEN 255
24 /* Maximum buffer size ( including the '\0' ).
26 #define MAX_BUFFER_LEN (MAX_ATOM_LEN + 1)
28 static LONG DDE_current_handle;
30 /* This is a simple list to keep track of the strings created
31 * by DdeCreateStringHandle. The list is used to free
32 * the strings whenever DdeUninitialize is called.
33 * This mechanism is not complete and does not handle multiple instances.
34 * Most of the DDE API use a DWORD parameter indicating witch instance
35 * of a given program is calling them. The API are supposed to
36 * associate the data to the instance that created it.
38 typedef struct tagHSZNode HSZNode;
45 /* Start off the list pointer with a NULL.
47 static HSZNode* pHSZNodes = NULL;
50 /******************************************************************************
51 * RemoveHSZNodes (INTERNAL)
53 * Remove a node from the list of HSZ nodes.
55 static void RemoveHSZNode( DWORD idInst, HSZ hsz )
57 HSZNode* pPrev = NULL;
58 HSZNode* pCurrent = NULL;
60 /* Set the current node at the start of the list.
63 /* While we have more nodes.
65 while( pCurrent != NULL )
67 /* If we found the node we were looking for.
69 if( pCurrent->hsz == hsz )
73 /* If the first node in the list is to to be removed.
74 * Set the global list pointer to the next node.
76 if( pCurrent == pHSZNodes )
78 pHSZNodes = pCurrent->next;
80 /* Just fix the pointers has to skip the current
81 * node so we can delete it.
85 pPrev->next = pCurrent->next;
92 /* Save the previous node pointer.
95 /* Move on to the next node.
97 pCurrent = pCurrent->next;
101 /******************************************************************************
102 * FreeAndRemoveHSZNodes (INTERNAL)
104 * Frees up all the strings still allocated in the list and
105 * remove all the nodes from the list of HSZ nodes.
107 static void FreeAndRemoveHSZNodes( DWORD idInst )
109 /* Free any strings created in this instance.
111 while( pHSZNodes != NULL )
113 DdeFreeStringHandle32( idInst, pHSZNodes->hsz );
117 /******************************************************************************
118 * InsertHSZNode (INTERNAL)
120 * Insert a node to the head of the list.
122 static void InsertHSZNode( DWORD idInst, HSZ hsz )
126 HSZNode* pNew = NULL;
127 /* Create a new node for this HSZ.
129 pNew = (HSZNode*) malloc( sizeof( HSZNode ) );
132 /* Set the handle value.
135 /* Attach the node to the head of the list.
137 pNew->next = pHSZNodes;
138 /* The new node is now at the head of the list
139 * so set the global list pointer to it.
147 /******************************************************************************
148 * DdeInitialize16 (DDEML.2)
150 UINT16 WINAPI DdeInitialize16( LPDWORD pidInst, PFNCALLBACK16 pfnCallback,
151 DWORD afCmd, DWORD ulRes)
153 return (UINT16)DdeInitialize32A(pidInst,(PFNCALLBACK32)pfnCallback,
158 /******************************************************************************
159 * DdeInitialize32A (USER32.106)
161 UINT32 WINAPI DdeInitialize32A( LPDWORD pidInst, PFNCALLBACK32 pfnCallback,
162 DWORD afCmd, DWORD ulRes )
164 return DdeInitialize32W(pidInst,pfnCallback,afCmd,ulRes);
168 /******************************************************************************
169 * DdeInitialize32W [USER32.107]
170 * Registers an application with the DDEML
173 * pidInst [I] Pointer to instance identifier
174 * pfnCallback [I] Pointer to callback function
175 * afCmd [I] Set of command and filter flags
179 * Success: DMLERR_NO_ERROR
180 * Failure: DMLERR_DLL_USAGE, DMLERR_INVALIDPARAMETER, DMLERR_SYS_ERROR
182 UINT32 WINAPI DdeInitialize32W( LPDWORD pidInst, PFNCALLBACK32 pfnCallback,
183 DWORD afCmd, DWORD ulRes )
185 FIXME(ddeml, "(%p,%p,0x%lx,%ld): stub\n",pidInst,pfnCallback,afCmd,ulRes);
191 ERR(dde, "Reserved value not zero? What does this mean?\n");
193 return DMLERR_NO_ERROR;
197 /*****************************************************************
198 * DdeUninitialize16 (DDEML.3)
200 BOOL16 WINAPI DdeUninitialize16( DWORD idInst )
202 return (BOOL16)DdeUninitialize32( idInst );
206 /*****************************************************************
207 * DdeUninitialize32 [USER32.119] Frees DDEML resources
210 * idInst [I] Instance identifier
216 BOOL32 WINAPI DdeUninitialize32( DWORD idInst )
219 FIXME(ddeml, "(%ld): stub\n", idInst);
221 /* Free the nodes that were not freed by this instance
222 * and remove the nodes from the list of HSZ nodes.
224 FreeAndRemoveHSZNodes( idInst );
230 /*****************************************************************
231 * DdeConnectList16 [DDEML.4]
233 HCONVLIST WINAPI DdeConnectList16( DWORD idInst, HSZ hszService, HSZ hszTopic,
234 HCONVLIST hConvList, LPCONVCONTEXT16 pCC )
236 return DdeConnectList32(idInst, hszService, hszTopic, hConvList,
237 (LPCONVCONTEXT32)pCC);
241 /******************************************************************************
242 * DdeConnectList32 [USER32.93] Establishes conversation with DDE servers
245 * idInst [I] Instance identifier
246 * hszService [I] Handle to service name string
247 * hszTopic [I] Handle to topic name string
248 * hConvList [I] Handle to conversation list
249 * pCC [I] Pointer to structure with context data
252 * Success: Handle to new conversation list
255 HCONVLIST WINAPI DdeConnectList32( DWORD idInst, HSZ hszService, HSZ hszTopic,
256 HCONVLIST hConvList, LPCONVCONTEXT32 pCC )
258 FIXME(ddeml, "(%ld,%ld,%ld,%ld,%p): stub\n", idInst, hszService, hszTopic,
264 /*****************************************************************
265 * DdeQueryNextServer16 [DDEML.5]
267 HCONV WINAPI DdeQueryNextServer16( HCONVLIST hConvList, HCONV hConvPrev )
269 return DdeQueryNextServer32(hConvList, hConvPrev);
273 /*****************************************************************
274 * DdeQueryNextServer32 [USER32.112]
276 HCONV WINAPI DdeQueryNextServer32( HCONVLIST hConvList, HCONV hConvPrev )
278 FIXME(ddeml, "(%ld,%ld): stub\n",hConvList,hConvPrev);
282 /*****************************************************************
283 * DdeQueryString32A [USER32.113]
285 DWORD WINAPI DdeQueryString32A(DWORD idInst, HSZ hsz, LPSTR psz, DWORD cchMax, INT32 iCodePage)
288 CHAR pString[MAX_BUFFER_LEN];
291 "(%ld, 0x%lx, %p, %ld, %d): stub\n",
298 if( iCodePage == CP_WINANSI )
300 /* If psz is null, we have to return only the length
306 cchMax = MAX_BUFFER_LEN;
309 ret = GlobalGetAtomName32A( hsz, (LPSTR)psz, cchMax );
315 /*****************************************************************
316 * DdeQueryString32W [USER32.114]
318 DWORD WINAPI DdeQueryString32W(DWORD idInst, HSZ hsz, LPWSTR psz, DWORD cchMax, INT32 iCodePage)
321 WCHAR pString[MAX_BUFFER_LEN];
325 "(%ld, 0x%lx, %p, %ld, %d): stub\n",
332 if( iCodePage == CP_WINUNICODE )
334 /* If psz is null, we have to return only the length
340 cchMax = MAX_BUFFER_LEN;
341 /* Note: According to documentation if the psz parameter
342 * was NULL this API must return the length of the string in bytes.
344 factor = (int) sizeof(WCHAR)/sizeof(BYTE);
346 ret = GlobalGetAtomName32W( hsz, (LPWSTR)psz, cchMax ) * factor;
352 /*****************************************************************
353 * DdeDisconnectList (DDEML.6)
355 BOOL16 WINAPI DdeDisconnectList16( HCONVLIST hConvList )
357 return (BOOL16)DdeDisconnectList32(hConvList);
361 /******************************************************************************
362 * DdeDisconnectList32 [USER32.98] Destroys list and terminates conversations
368 BOOL32 WINAPI DdeDisconnectList32(
369 HCONVLIST hConvList) /* [in] Handle to conversation list */
371 FIXME(ddeml, "(%ld): stub\n", hConvList);
376 /*****************************************************************
377 * DdeConnect16 (DDEML.7)
379 HCONV WINAPI DdeConnect16( DWORD idInst, HSZ hszService, HSZ hszTopic,
380 LPCONVCONTEXT16 pCC )
382 FIXME( ddeml, "empty stub\n" );
387 /*****************************************************************
388 * DdeConnect32 (USER32.92)
390 HCONV WINAPI DdeConnect32( DWORD idInst, HSZ hszService, HSZ hszTopic,
391 LPCONVCONTEXT32 pCC )
393 FIXME(ddeml, "(0x%lx,%ld,%ld,%p): stub\n",idInst,hszService,hszTopic,
399 /*****************************************************************
400 * DdeDisconnect16 (DDEML.8)
402 BOOL16 WINAPI DdeDisconnect16( HCONV hConv )
404 return (BOOL16)DdeDisconnect32( hConv );
407 /*****************************************************************
408 * DdeSetUserHandle (DDEML.10)
410 BOOL16 WINAPI DdeSetUserHandle( HCONV hConv, DWORD id, DWORD hUser )
412 FIXME( ddeml, "(%ld,%ld,%ld): stub\n",hConv,id, hUser );
416 /*****************************************************************
417 * DdeCreateDataHandle16 (DDEML.14)
419 HDDEDATA WINAPI DdeCreateDataHandle16( DWORD idInst, LPBYTE pSrc, DWORD cb,
420 DWORD cbOff, HSZ hszItem, UINT16 wFmt,
423 return DdeCreateDataHandle32(idInst,
432 /*****************************************************************
433 * DdeCreateDataHandle32 (USER32.94)
435 HDDEDATA WINAPI DdeCreateDataHandle32( DWORD idInst, LPBYTE pSrc, DWORD cb,
436 DWORD cbOff, HSZ hszItem, UINT32 wFmt,
440 "(%ld,%p,%ld,%ld,0x%lx,%d,%d): stub\n",
452 /*****************************************************************
453 * DdeDisconnect32 (USER32.97)
455 BOOL32 WINAPI DdeDisconnect32( HCONV hConv )
457 FIXME( ddeml, "empty stub\n" );
462 /*****************************************************************
463 * DdeReconnect (DDEML.37) (USER32.115)
465 HCONV WINAPI DdeReconnect( HCONV hConv )
467 FIXME( ddeml, "empty stub\n" );
472 /*****************************************************************
473 * DdeCreateStringHandle16 (DDEML.21)
475 HSZ WINAPI DdeCreateStringHandle16( DWORD idInst, LPCSTR str, INT16 codepage )
477 return DdeCreateStringHandle32A( idInst, str, codepage );
481 /*****************************************************************
482 * DdeCreateStringHandle32A [USER32.95]
485 * Success: String handle
488 HSZ WINAPI DdeCreateStringHandle32A( DWORD idInst, LPCSTR psz, INT32 codepage )
491 TRACE(ddeml, "(%ld,%s,%d): stub\n",idInst,debugstr_a(psz),codepage);
493 if (codepage==CP_WINANSI)
495 hsz = GlobalAddAtom32A (psz);
496 /* Save the handle so we know to clean it when
497 * uninitialize is called.
499 InsertHSZNode( idInst, hsz );
506 /******************************************************************************
507 * DdeCreateStringHandle32W [USER32.96] Creates handle to identify string
510 * Success: String handle
513 HSZ WINAPI DdeCreateStringHandle32W(
514 DWORD idInst, /* [in] Instance identifier */
515 LPCWSTR psz, /* [in] Pointer to string */
516 INT32 codepage) /* [in] Code page identifier */
520 FIXME(ddeml, "(%ld,%s,%d): stub\n",idInst,debugstr_w(psz),codepage);
522 if (codepage==CP_WINUNICODE)
524 hsz = GlobalAddAtom32W (psz);
525 /* Save the handle so we know to clean it when
526 * uninitialize is called.
528 InsertHSZNode( idInst, hsz );
535 /*****************************************************************
536 * DdeFreeStringHandle16 (DDEML.22)
538 BOOL16 WINAPI DdeFreeStringHandle16( DWORD idInst, HSZ hsz )
540 return (BOOL32)DdeFreeStringHandle32( idInst, hsz );
544 /*****************************************************************
545 * DdeFreeStringHandle32 (USER32.101)
546 * RETURNS: success: nonzero
549 BOOL32 WINAPI DdeFreeStringHandle32( DWORD idInst, HSZ hsz )
551 TRACE( ddeml, "(%ld,%ld): stub\n",idInst, hsz );
552 /* Remove the node associated with this HSZ.
554 RemoveHSZNode( idInst, hsz );
555 /* Free the string associated with this HSZ.
557 return GlobalDeleteAtom (hsz) ? 0 : hsz;
561 /*****************************************************************
562 * DdeFreeDataHandle16 (DDEML.19)
564 BOOL16 WINAPI DdeFreeDataHandle16( HDDEDATA hData )
566 return (BOOL32)DdeFreeDataHandle32( hData );
570 /*****************************************************************
571 * DdeFreeDataHandle32 (USER32.100)
573 BOOL32 WINAPI DdeFreeDataHandle32( HDDEDATA hData )
575 FIXME( ddeml, "empty stub\n" );
582 /*****************************************************************
583 * DdeKeepStringHandle16 (DDEML.24)
585 BOOL16 WINAPI DdeKeepStringHandle16( DWORD idInst, HSZ hsz )
587 return (BOOL32)DdeKeepStringHandle32( idInst, hsz );
591 /*****************************************************************
592 * DdeKeepStringHandle32 (USER32.108)
594 BOOL32 WINAPI DdeKeepStringHandle32( DWORD idInst, HSZ hsz )
596 FIXME( ddeml, "empty stub\n" );
601 /*****************************************************************
602 * DdeClientTransaction16 (DDEML.11)
604 HDDEDATA WINAPI DdeClientTransaction16( LPVOID pData, DWORD cbData,
605 HCONV hConv, HSZ hszItem, UINT16 wFmt,
606 UINT16 wType, DWORD dwTimeout,
609 return DdeClientTransaction32( (LPBYTE)pData, cbData, hConv, hszItem,
610 wFmt, wType, dwTimeout, pdwResult );
614 /*****************************************************************
615 * DdeClientTransaction32 (USER32.90)
617 HDDEDATA WINAPI DdeClientTransaction32( LPBYTE pData, DWORD cbData,
618 HCONV hConv, HSZ hszItem, UINT32 wFmt,
619 UINT32 wType, DWORD dwTimeout,
622 FIXME( ddeml, "empty stub\n" );
626 /*****************************************************************
627 * DdeAbandonTransaction (DDEML.12)
629 BOOL16 WINAPI DdeAbandonTransaction( DWORD idInst, HCONV hConv,
630 DWORD idTransaction )
632 FIXME( ddeml, "empty stub\n" );
637 /*****************************************************************
638 * DdePostAdvise16 [DDEML.13]
640 BOOL16 WINAPI DdePostAdvise16( DWORD idInst, HSZ hszTopic, HSZ hszItem )
642 return (BOOL16)DdePostAdvise32(idInst, hszTopic, hszItem);
646 /******************************************************************************
647 * DdePostAdvise32 [USER32.110] Send transaction to DDE callback function.
653 BOOL32 WINAPI DdePostAdvise32(
654 DWORD idInst, /* [in] Instance identifier */
655 HSZ hszTopic, /* [in] Handle to topic name string */
656 HSZ hszItem) /* [in] Handle to item name string */
658 FIXME(ddeml, "(%ld,%ld,%ld): stub\n",idInst,hszTopic,hszItem);
663 /*****************************************************************
664 * DdeAddData (DDEML.15)
666 HDDEDATA WINAPI DdeAddData( HDDEDATA hData, LPBYTE pSrc, DWORD cb,
669 FIXME( ddeml, "empty stub\n" );
674 /******************************************************************************
675 * DdeGetData32 [USER32.102] Copies data from DDE object ot local buffer
678 * Size of memory object associated with handle
680 DWORD WINAPI DdeGetData32(
681 HDDEDATA hData, /* [in] Handle to DDE object */
682 LPBYTE pDst, /* [in] Pointer to destination buffer */
683 DWORD cbMax, /* [in] Amount of data to copy */
684 DWORD cbOff) /* [in] Offset to beginning of data */
686 FIXME(ddeml, "(%ld,%p,%ld,%ld): stub\n",hData,pDst,cbMax,cbOff);
691 /*****************************************************************
692 * DdeGetData16 [DDEML.16]
694 DWORD WINAPI DdeGetData16(
700 return DdeGetData32(hData, pDst, cbMax, cbOff);
704 /*****************************************************************
705 * DdeAccessData16 (DDEML.17)
707 LPBYTE WINAPI DdeAccessData16( HDDEDATA hData, LPDWORD pcbDataSize )
709 return DdeAccessData32(hData, pcbDataSize);
712 /*****************************************************************
713 * DdeAccessData32 (USER32.88)
715 LPBYTE WINAPI DdeAccessData32( HDDEDATA hData, LPDWORD pcbDataSize )
717 FIXME( ddeml, "(%ld,%p): stub\n", hData, pcbDataSize);
721 /*****************************************************************
722 * DdeUnaccessData16 (DDEML.18)
724 BOOL16 WINAPI DdeUnaccessData16( HDDEDATA hData )
726 return DdeUnaccessData32(hData);
729 /*****************************************************************
730 * DdeUnaccessData32 (USER32.118)
732 BOOL32 WINAPI DdeUnaccessData32( HDDEDATA hData )
734 FIXME( ddeml, "(0x%lx): stub\n", hData);
739 /*****************************************************************
740 * DdeEnableCallback16 (DDEML.26)
742 BOOL16 WINAPI DdeEnableCallback16( DWORD idInst, HCONV hConv, UINT16 wCmd )
744 return DdeEnableCallback32(idInst, hConv, wCmd);
747 /*****************************************************************
748 * DdeEnableCallback32 (USER32.99)
750 BOOL32 WINAPI DdeEnableCallback32( DWORD idInst, HCONV hConv, UINT32 wCmd )
752 FIXME( ddeml, "(%ld, 0x%lx, %d) stub\n", idInst, hConv, wCmd);
757 /*****************************************************************
758 * DdeNameService16 (DDEML.27)
760 HDDEDATA WINAPI DdeNameService16( DWORD idInst, HSZ hsz1, HSZ hsz2,
763 return DdeNameService32( idInst, hsz1, hsz2, afCmd );
767 /******************************************************************************
768 * DdeNameService32 [USER32.109] {Un}registers service name of DDE server
771 * idInst [I] Instance identifier
772 * hsz1 [I] Handle to service name string
774 * afCmd [I] Service name flags
780 HDDEDATA WINAPI DdeNameService32( DWORD idInst, HSZ hsz1, HSZ hsz2,
783 FIXME(ddeml, "(%ld,%ld,%ld,%d): stub\n",idInst,hsz1,hsz2,afCmd);
788 /*****************************************************************
789 * DdeGetLastError16 (DDEML.20)
791 UINT16 WINAPI DdeGetLastError16( DWORD idInst )
793 return (UINT16)DdeGetLastError32( idInst );
797 /******************************************************************************
798 * DdeGetLastError32 [USER32.103] Gets most recent error code
801 * idInst [I] Instance identifier
806 UINT32 WINAPI DdeGetLastError32( DWORD idInst )
808 FIXME(ddeml, "(%ld): stub\n",idInst);
813 /*****************************************************************
814 * DdeCmpStringHandles16 (DDEML.36)
816 int WINAPI DdeCmpStringHandles16( HSZ hsz1, HSZ hsz2 )
818 return DdeCmpStringHandles32(hsz1, hsz2);
821 /*****************************************************************
822 * DdeCmpStringHandles32 (USER32.91)
824 * Compares the value of two string handles. This comparison is
825 * not case sensitive.
828 * -1 The value of hsz1 is zero or less than hsz2
829 * 0 The values of hsz 1 and 2 are the same or both zero.
830 * 1 The value of hsz2 is zero of less than hsz1
832 int WINAPI DdeCmpStringHandles32( HSZ hsz1, HSZ hsz2 )
834 CHAR psz1[MAX_BUFFER_LEN];
835 CHAR psz2[MAX_BUFFER_LEN];
839 TRACE( ddeml, "handle 1, handle 2\n" );
841 ret1 = GlobalGetAtomName32A( hsz1, psz1, MAX_BUFFER_LEN );
842 ret2 = GlobalGetAtomName32A( hsz2, psz2, MAX_BUFFER_LEN );
843 /* Make sure we found both strings.
845 if( ret1 == 0 && ret2 == 0 )
847 /* If both are not found, return both "zero strings".
853 /* If hsz1 is a not found, return hsz1 is "zero string".
859 /* If hsz2 is a not found, return hsz2 is "zero string".
865 /* Compare the two strings we got ( case insensitive ).
867 ret = strcasecmp( psz1, psz2 );
868 /* Since strcmp returns any number smaller than
869 * 0 when the first string is found to be less than
870 * the second one we must make sure we are returning
886 /*****************************************************************
887 * PackDDElParam (USER32.414)
893 UINT32 WINAPI PackDDElParam(UINT32 msg, UINT32 uiLo, UINT32 uiHi)
895 FIXME(ddeml, "stub.\n");
900 /*****************************************************************
901 * UnpackDDElParam (USER32.562)
907 UINT32 WINAPI UnpackDDElParam(UINT32 msg, UINT32 lParam,
908 UINT32 *uiLo, UINT32 *uiHi)
910 FIXME(ddeml, "stub.\n");
915 /*****************************************************************
916 * FreeDDElParam (USER32.204)
922 UINT32 WINAPI FreeDDElParam(UINT32 msg, UINT32 lParam)
924 FIXME(ddeml, "stub.\n");
928 /*****************************************************************
929 * ReuseDDElParam (USER32.446)
932 UINT32 WINAPI ReuseDDElParam(UINT32 lParam, UINT32 msgIn, UINT32 msgOut,
933 UINT32 uiLi, UINT32 uiHi)
935 FIXME(ddeml, "stub.\n");