STK与vs2013连接

连接的源码

/*************************************************************************
* For Customer Support contact Analytical Graphics, Inc. at www.agi.com *
*************************************************************************/
#include "AgConnect.h"
#include <stdio.h>
#include <stdlib.h>
#include <iostream>				


extern "C" {
	const char* AgEAppName = _T("ConnectExample");
}

int main()
{

	char* connection1 = NULL;
	char* initFileName = NULL;
	static const char  connectName[256] = _T("localhost:5001");

	AgTConReturnInfo returnInfo;

	static char  cmdString1[256] =
	{ _T("Load / VDF \"{Your install location goes here}\\Data\\ExampleScenarios\\Intro_STK_Aircraft_Systems.vdf\"") };
	static char  cmdString2[256] = _T("AllAccess / ElimDups");
	int   i;


	/* Initialize Connect */

	AgConInit(initFileName);

	/* Open a connection to STK */

	AgConOpenSTK(&connection1, 0, connectName);

	/* Set verbose and ack on */

	AgConSetProperties(connection1, (AgCConVerboseOn | AgCConAckOn));

	/* Begin sending IPC Commands */

	AgConProcessSTKCmd(connection1, cmdString1, &returnInfo);

	/*
	* The first command, Load, returns no data, so no need
	* to free memory allocated to returnInfo.
	*/

	AgConProcessSTKCmd(connection1, cmdString2, &returnInfo);

	/* Finished sending commands, close the connection */

	AgConCloseSTK(&connection1);

	/*  Print out the results of the AllAccess command */

	for (i = 0; i < returnInfo.numEntries; i++)
	{
		AgUtMsg(AgCMsgForceInfo, AgCMsgNoWait, AgCMsgDispDefault, AgCMsgNoErrorCode,
			AgCMSourceLine, _T("Return entry %d:\n%s\n"), i + 1, returnInfo.returnList[i]);
	}

	/*  Clean up the Return Information, freeing any unneeded memory */

	AgConCleanupReturnInfo(&returnInfo);

	/*  Free remaining allocated memory in the Connect module in
	*  preparation for exit
	*/

	AgConShutdownConnect();

	std::cout << "Press enter to exit...\n";
	std::cin.get();

	return (0);
}

可能发生的问题:
1.如果AgCMSourceLine报错显示“TFILE无定义”,根据文件查找定义发现可能是字符unicode是或非的问题与项目属性发生冲突,那么检查项目文件的属性,然后将字符集改为无定义即可。
2.如果运行结果并没有连接上,则先启动STK即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值