?? s2l4.cpp
字號:
//####################################################################
// S2L4.cpp - (Section 2, Lesson 4) SENDING AN INTEGER TO THE TARGET
// This is the RTDX Host Client for Section 2, Lesson 4
//
// This example sends integer value 5 to the target
//####################################################################
#import "..\..\..\..\..\cc\bin\rtdxint.dll"
#include <iostream.h>
#define VALUE_TO_SEND 5
using namespace RTDXINTLib;
int main()
{
IRtdxExpPtr rtdx; // holds pointer to IRtdxExp interface
long status; // holds status of RTDX COM API calls
HRESULT hr; // holds status of generic COM API calls
short data=VALUE_TO_SEND; // holds data to be sent to target
long bufferstate; // holds the state of the host's write buffer
// initialize COM
::CoInitialize( NULL );
// instantiate the RTDX COM Object
hr = rtdx.CreateInstance( L"RTDX" );
cout.setf( ios::showbase );
if ( FAILED(hr) ) {
cerr << hex << hr << " - Error: Instantiation failed! \n";
return -1;
}
// open a channel (ichan) for writing
status = rtdx->Open( "ichan", "W" );
if ( status != Success ) {
cerr << hex << status \
<< " - Error: Opening of channel \"ichan\" failed! \n";
return -1;
}
// send a 16-bit integer to the target
rtdx->WriteI2( data, &bufferstate );
if ( status != Success ) {
cerr << hex << status << " - Error: WriteI2 failed!\n";
return -1;
}
cout << "Value " << data << " was sent to the target!\n";
// close the channel
status = rtdx->Close();
// release the RTDX COM Object
rtdx.Release();
// unitialize COM
::CoUninitialize();
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -