iCAx开思工具箱
标题:
DLL可以调用DLL吗
[打印本页]
作者:
cam-yp
时间:
2009-4-2 15:09
标题:
DLL可以调用DLL吗
假设有2个dll
1个是建立方块的 -> 1.DLL
1个是建立圆柱的 -> 2.DLL
我想在1.DLL中运行2.DLL创建圆柱,能实现吗?
作者:
open_lian
时间:
2009-4-2 16:52
不会,帮你顶一个:food:
作者:
oucaipin
时间:
2009-4-3 15:01
可以的!!!!
作者:
daojianrm
时间:
2009-4-7 11:08
可以,可以实现
作者:
cam-yp
时间:
2009-4-7 12:20
daojianrm 发表于 2009-4-7 11:08
可以,可以实现
有例子吗
作者:
zzrxt
时间:
2009-4-10 19:31
#include <ctype.h>
#include <stdio.h>
#include <uf.h>
#include <error_bases.h>
#define MAX_INPUT_SIZE (8) /* Larger than needed input buffer. */
typedef int (*XMPL_f_p_t)( int argc, char *argv[] );
/*****************************************************************
Please add the correct file extension for a particular platform as follows:
HP - .sl
Windows NT - .dll
Digital Unix, IBM/AIX, SUN, SGI - .so
*/
#define XMPL_SHLIB ("ufd_example_shlib")
#define XMPL_FNC_A ("ep_a")
#define XMPL_FNC_B ("ep_b")
/*****************************************************************
*
* Loads a library and finds the function entry point specified by
* the symbol name (sym), if necessary. Calls the function with
* supplied arguments and returns status. The function pointer is
* output for future use.
*
***/
static int execute_lib(
char *lib, /* I - Library Name. */
char *sym, /* I - Symbol Name. */
int argc, /* I - Argument Count. */
char *argv[], /* I - Arguments. */
XMPL_f_p_t *fnc ) /* IO - Function Pointer for 'sym'.*/
{
int error;
/* Load library if necessary... */
if( NULL == *fnc )
{
UF_load_f_p_t generic_fnc;
if( !(error = UF_load_library( lib, sym, &generic_fnc )) )
{
*fnc = (XMPL_f_p_t) generic_fnc;
}
else /* Library load failed... */
{
char message[133];
UF_get_fail_message( error, message );
fprintf( stderr,
"ERROR: While loading \"%s\" (%s)...\n\t%s\n", lib, sym,
message );
}
}
else
error = ERROR_OK;
/* Execute function... */
if( NULL != *fnc )
error = (**fnc)( argc, argv );
return( error );
}
/*****************************************************************
*
* A simple program to demonstrate dynamic loading and
* unloading of shared libraries using UF_load_library
* and UF_unload_library. The program allows the user
* to select one of two libraries to load and execute,
* unload both libraries, or terminate the program. Target
* function prototypes are expected to match the 'C' 'main'
* prototype (i.e. int fnc(int argc, char *argv[])).
*
***/
/*ARGSUSED*/
extern int main(
int argc,
char *argv[] )
{
int error;
if( !(error = UF_initialize()) )
{
int done;
done = 0;
do
{
char input[MAX_INPUT_SIZE+1];
/* Display user choices... */
printf( "\n\n" );
printf( " 1 - Load and execute \"%s\" function.\n",
XMPL_FNC_A );
printf( " 2 - Load and execute \"%s\" function.\n",
XMPL_FNC_B );
printf( " 3 - Unload libraries.\n" );
printf( " 4 - Terminate.\n\n" );
printf( "Enter selection: " );
/* Get user selection. */
fgets( input, sizeof(input), stdin );
printf( "\n\n" );
/* Selection must be a single digit. */
if( isdigit(input[0]) && '\n' == input[1] )
{
static XMPL_f_p_t fnc_a = NULL;
static XMPL_f_p_t fnc_b = NULL;
/* Process selection... */
switch( input[0] )
{
case '1': /* Load and execute first function... */
{
char *xmpl_argv[] =
{
XMPL_SHLIB, /* Library to load. */
XMPL_FNC_A, /* Function to execute. */
"Called function ep_a in library ufd_example_shlib."
};
int xmpl_argc = sizeof(xmpl_argv) /
sizeof(*xmpl_argv);
error = execute_lib( xmpl_argv[0], xmpl_argv[1],
xmpl_argc, xmpl_argv, &fnc_a );
}
break;
case '2': /* Load and execute second function... */
{
char *xmpl_argv[] =
{
XMPL_SHLIB, /* Library to load. */
XMPL_FNC_B, /* Function to execute. */
"Called function ep_b in library ufd_example_shlib."
};
int xmpl_argc = sizeof(xmpl_argv) /
sizeof(*xmpl_argv);
error = execute_lib( xmpl_argv[0], xmpl_argv[1],
xmpl_argc, xmpl_argv, &fnc_b );
}
break;
case '3': /* Unload library... */
UF_unload_library( XMPL_SHLIB );
fnc_a = NULL;
fnc_b = NULL;
break;
case '4': /* Finished - set termination flag. */
done = 1;
break;
default: /* Input character is out of range... */
fprintf( stderr, "\nERROR: Invalid selection.\n" );
break;
}
}
else
fprintf( stderr, "\nERROR: Select with digit only.\n" );
} while( !done && !error );
UF_terminate();
}
else
{
char message[133];
UF_get_fail_message( error, message );
fprintf( stderr, "ERROR: %s\n", message );
}
return( 0 );
}
杨兄,以上代码可调用OK,
例: D:\UGS\NX 4.0\UGOPEN\ufd_load_library.c
作者:
cam-yp
时间:
2009-4-11 08:28
我要实现的就是类似XSPAWN的功能
XSPAWN/UFUN,'program name'[,IFERR,label:]这个就是grip执行DLL的函数,不管DLL里面有什么东西,只管执行就ok
作者:
zzrxt
时间:
2009-4-14 18:54
可以的.......
欢迎光临 iCAx开思工具箱 (https://t.icax.org/)
Powered by Discuz! X3.3