VS2010添加DCMTK库,并实现Echo SCU

当DCMTK库编译通过后就可以使用了,但是怎么使用?

在vs2010新建工程后,要把工程和DCMTK库链接起来。在工程上面点击右键,选择属性

1、配置属性->VC++目录->包含目录,添加include目录

2、配置属性->链接器->常规->附加库目录,添加lib目录

3、配置属性->C/C++->代码生成->运行库,选择多线程调试 (/MTd)

4、配置属性->链接器->输入->附加依赖选项,添加

dcmnet.lib
netapi32.lib
ofstd.lib
oflog.lib
wsock32.lib
dcmdata.lib

具体添加哪些lib库文件,其实还要看你用的函数和类,函数和类在那个lib库文件中,就要把这个库文件添加进来

之后就可以写代码测试了,自己写还不懂,我是使用DCMTK帮助文档来测试的,这段代码在帮助文档的dcmtk-3.6.0-html-help/mod_dcmnet.html这个位置。

scp是用DCMTK的storescp.exe。

在cmd窗口,bin目录下,

storescp.exe -v  104

来开启scp服务,104是监听端口

测试代码:

#include"dcmtk/dcmnet/assoc.h"
#include"dcmtk/dcmnet/dimse.h"

int main()
{
	T_ASC_Network *net; // network struct, contains DICOM upper layer FSM etc.
	ASC_initializeNetwork(NET_REQUESTOR, 0, 1000 /* timeout */, &net);

	T_ASC_Parameters *params; // parameters of association request
	ASC_createAssociationParameters(¶ms, ASC_DEFAULTMAXPDU);

	// set calling and called AE titles
	ASC_setAPTitles(params, "ECHOSCU", "ANY-SCP", NULL);

	// the DICOM server accepts connections at server.nowhere.com port 104
	ASC_setPresentationAddresses(params, "localhost", "SCP_IP:104");//这里要替换SCP_IP

	// list of transfer syntaxes, only a single entry here
	const char* ts[] = { UID_LittleEndianImplicitTransferSyntax };

	// add presentation context to association request
	ASC_addPresentationContext(params, 1, UID_VerificationSOPClass, ts, 1);

	// request DICOM association
	T_ASC_Association *assoc;
	if (ASC_requestAssociation(net, params, &assoc).good())
	{
		if (ASC_countAcceptedPresentationContexts(params) == 1)
		{
		// the remote SCP has accepted the Verification Service Class
		DIC_US id = assoc->nextMsgID++; // generate next message ID
		DIC_US status; // DIMSE status of C-ECHO-RSP will be stored here
		DcmDataset *sd = NULL; // status detail will be stored here
		// send C-ECHO-RQ and handle response
		DIMSE_echoUser(assoc, id, DIMSE_BLOCKING, 0, &status, &sd);
		delete sd; // we don't care about status detail
		}
	}
	ASC_releaseAssociation(assoc); // release association
	ASC_destroyAssociation(&assoc); // delete assoc structure
	ASC_dropNetwork(&net); // delete net structure
}


  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值