WSUserData (C 函数)
void * WSUserData(WSLINK link,WSUserFunction *fp)
返回由 WSSetUserData() 安装的数据对象和函数指针.
范例
基本范例 (1)
#include <stdlib.h>
#include "wstp.h"
typedef struct foo_ {
int member;
} foo;
int main(int argc, char **argv)
{
WSENV env;
WSLINK link;
int error;
foo *fobj;
fobj = (foo *)malloc(sizeof(foo));
if(fobj == (foo *)0)
{ /* unable to allocate memory for foo object */ }
env = WSInitialize((WSEnvironmentParameter)0);
if(env == (WSENV)0)
{ /* unable to initialize WSTP environment */ }
link = WSOpenArgcArgv(env, argc, argv, &error);
if(link == (WSLINK)0 || error != WSEOK)
{ /* unable to create link object */ }
WSSetUserData(link, (void *)fobj, (WSUserFunction)0);
/* ... */
fobj = WSUserData(link, (WSUserFunction *)0);
free(fobj);
WSClose(link);
WSDeinitialize(env);
return 0;
}