📄 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
long 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 32-bit integer to the target
rtdx->WriteI4( data, &bufferstate );
if ( status != Success ) {
cerr << hex << status << " - Error: WriteI4 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 + -