1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ddewrap.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 // MARKER(update_precomp.py): autogen include statement, do not remove
33 #include "precompiled_svtools.hxx"
34 #define _SVTOOLS_SVDDE_DDEWRAP_CXX_
37 #pragma warning(push, 1)
43 #include "ddewrap.hxx"
45 //------------------------------------------------------------------------
47 HSZ WINAPI
DdeCreateStringHandleW_9x( DWORD idInst
, LPCWSTR pszString
, int )
53 nSize
= pszString
? WideCharToMultiByte( CP_ACP
, 0, pszString
, -1, NULL
, 0, NULL
, NULL
) : 0;
54 pszANSIString
= nSize
? (LPSTR
)HeapAlloc( GetProcessHeap(), 0, nSize
* sizeof(CHAR
) ) : NULL
;
57 WideCharToMultiByte( CP_ACP
, 0, pszString
, -1, pszANSIString
, nSize
, NULL
, NULL
);
59 hszResult
= DdeCreateStringHandleA( idInst
, pszANSIString
, CP_WINANSI
);
62 HeapFree( GetProcessHeap(), 0, pszANSIString
);
67 //------------------------------------------------------------------------
69 DWORD WINAPI
DdeQueryStringW_9x( DWORD idInst
, HSZ hsz
, LPWSTR pszString
, DWORD cchMax
, int )
74 pszANSIString
= cchMax
? (LPSTR
)HeapAlloc( GetProcessHeap(), 0, cchMax
* sizeof(CHAR
) ) : NULL
;
76 dwResult
= DdeQueryStringA( idInst
, hsz
, pszANSIString
, cchMax
, CP_WINANSI
);
78 if ( dwResult
&& pszANSIString
)
79 MultiByteToWideChar( CP_ACP
, 0, pszANSIString
, -1, pszString
, cchMax
);
82 HeapFree( GetProcessHeap(), 0, pszANSIString
);
87 //------------------------------------------------------------------------
89 UINT WINAPI
DdeInitializeW_9x( LPDWORD pidInst
, PFNCALLBACK pfnCallback
, DWORD afCmd
, DWORD ulRes
)
91 return DdeInitializeA( pidInst
, pfnCallback
, afCmd
, ulRes
);
94 //------------------------------------------------------------------------
96 #define DEFINE_WAPI_FUNC(func) \
97 func##_PROC lpfn##func = (LONG)GetVersion() >= 0 ? func : func##_9x;
100 DEFINE_WAPI_FUNC( DdeCreateStringHandleW
);
101 DEFINE_WAPI_FUNC( DdeQueryStringW
);
102 DEFINE_WAPI_FUNC( DdeInitializeW
);