資源簡介
NCDDE服務(wù)連接DDE封裝的API,ddehelper
使用c++語言
int GetData(LPSTR lpszDataName,std::string & data);
//HDDEDATA CALLBACK DDECallback(UINT uType, UINT uFmt, HCONV hconv, HSZ hszTopic, HSZ hszItem, HDDEDATA hdata, DWORD dwData1, DWORD dwData2);
static HDDEDATA CALLBACK DDEMyCallback(UINT uType, UINT uFmt, HCONV hconv, HSZ hszTopic, HSZ hszItem, HDDEDATA hdata, DWORD dwData1, DWORD dwData2);
//int ExecCmd(LPSTR app, LPSTR lpszCmd);
PTSTR GetTextData( HDDEDATA hData) ;
std::string DDERequest(std::string item);
void DDEAyncExecute(DWORD idInst, char* szCommand);
void DDEPoke(DWORD idInst, char* szItem, char* szData);
std::string DDEErrorMessage(UINT err);
std::string DdeAyncRequest(std::string item);
int DDEAdapter::TryRequest(std::string item, int format, int timeout, std::string &data);

代碼片段和文件信息
//==============================================================================================
//
//?DDEapi.cpp
//
//?This?software?was?developed?by?U.S.?Government?employees?as?part?of
//?their?official?duties?and?is?not?subject?to?copyright.?No?warranty?implied?
//?or?intended.Any?questions?or?comments?mailto:John.Michaloski@nist.gov
/*
It?uses?the?DDE?execute?facility?for?dealing?with?Word.??Each?call?to
an?API?here?causes?a?DDE?conversation?to?be?set?up?the?execute
request?made?and?the?conversation?terminated.
Example:
SendExecCmd(“WinWord“?“[FileOpen(\“c:\\michaloski\\worddoc.doc\“)][FilePrint?0][DocClose?2]“);
DE?is?a?means?for?one?application?(the?client)?to?communicate?with?another?(the?server)?via?messages.?The?client?can?send?commands?and?data?to?the?server?which?will?run?the?commands?and?process?the?data.?This?exchange?of?messages?is?called?a?conversation.
Conversations?are?about?a?topic.?Think?of?a?topic?as?the?fundamental?data?grouping?used?in?an?application.?A?workbook?in?Excel?or?a?form?in?VB?for?instance.?Topics?can?be?about?a?specific?item?say?a?particular?Excel?spreadsheet?cell.
Lets?look?at?an?example?of?sending?data?to?a?cell?in?Excel.?With?this?app?and?Excel?running?the?first?step?is?to?register?this?application?with?the?DDEML.?This?is?accomplished?with?a?call?to?the?DdeInitialize?API?when?you?click?the?Initialize?button.?Conversly?the?DdeUninitialize?function?is?used?to?free?all?DDEML?resources?when?our?conversation?is?complete.
Next?we?need?to?describe?our?conversation.?The?service?or?process?that?we?will?converse?with?is?“Excel“?and?the?topic?is?the?“book1“?workbook.?For?the?item?we?can?specify?a?cell?such?as?“R1C1“?and?we?can?use?a?value?of?“test“.
After?these?values?are?entered?into?the?corresponding?textboxes?the?Poke?button?can?be?pressed.?This?uses?the?DdeCreateStringHandle?function?to?convert?our?conversation?parameters?into?memory?handles.?A?call?to?DdeConnect?establishes?a?conversation?with?a?server?application?that?supports?the?specified?service?name?and?topic?and?returns?a?handle?to?the?conversation.
Once?a?conversation?is?established?the?DdeClientTransaction?API?transfers?the?actual?data?to?the?server?(Excel)?application.?DdeClientTransaction?call?uses?a?Poke?transaction?type?which?means?“send?unsolicited?data“?to?the?server?application.
The?Execute?and?Request?buttons?perfom?similar?functions?but?use?“Execute“?and?“Request“?type?transactions.?Execute?is?used?to?send?a?command?string?to?the?server?while?Request?asks?the?server?for?data.
*/
#include?“stdafx.h“
#include?
#include?
#include?
#include?
#include?“DDEapi.h“
#include?“StdStringFcn.h“
/****************************************************************************?
*?Callback?function?for?DDE?messages.
*??@parameter?wType
*??@parameter?wFmt
*??@parameter?hConv
*??@parameter?hsz1
*??@parameter?hsz2
*??@parameter?hDDEData
*??@parameter?dwData1
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1885??2017-02-06?10:33??DDEapi.h
?????文件??????21988??2017-03-23?21:27??DDEapi.cpp
-----------?---------??----------?-----??----
????????????????23873????????????????????2
- 上一篇:sln轉(zhuǎn)換dsw
- 下一篇:計(jì)步器程序
評論
共有 條評論