DLL Aufruf klappt nicht.. Programm bleibt einfach stehen..
Verfasst: 11.11.2004 15:03
Ich versuche gerade ein kleines Programm von c++ in PB zu übersetzen.
Das Programm greift auf eine Api Dll zu.
Wenn ich die Funktionen aus der DLL aufrufen will bricht das Programm
Kommentarlos ab.
c++ Programm:
die ersten Zeilen des Programmes sind:
Das [c]"Hallo"[/c] wird schon nicht mehr angezeigt.
Was mache ich bloß falsch?
Edit by NicTheQuick: Code-Tags gesetzt
Das Programm greift auf eine Api Dll zu.
Wenn ich die Funktionen aus der DLL aufrufen will bricht das Programm
Kommentarlos ab.
c++ Programm:
Code: Alles auswählen
/*
* ARIS Repository API sample program (step04.exe)
*
* Copyright (c) 1998 - 2000 by IDS Scheer AG
* All Rights Reserved.
*
* >> show all groups and models using the user default <<
* >> language in a selected ARIS database <<
*
* This short sample code initializes the first platform, prompts
* for a server to loggon and shows the available databases at the
* specified server. After opening the specified database with
* system/manager, the user default language and the configuration
* FULLMETHOD, all groups and models will be displayed at the
* screen. If any error appears the error text will be shown at
* the screen and the sample program aborts immediately.
*/
#ifndef _API_ARISAPI_H
# include "arisapi.h"
#endif
#ifndef _INC_STDIO
# include <stdio.h>
#endif
#ifndef _INC_STDLIB
# include <stdlib.h>
#endif
#ifndef _INC_STRING
# include <string.h>
#endif
#ifndef __wtypes_h__
# include <wtypes.h>
#endif
/* global error handling function, which will be called by
each ARIS Repository API error appeared */
void myErrorHandler( ArisErrorRec *pError )
{
char Text[_MAX_ERROR_TEXT];
/* check if the error is stranger than a warning by the severity */
if( ArisErrorGetSeverity( pError ) != _ARIS_ERROR_LOW ) {
/* if the error is not just a warning, the error text
will be printed to screen and the program aborts. */
ArisErrorGetText( Text, sizeof( Text ), pError );
printf( "\n* %s\n\n", Text );
exit( EXIT_FAILURE );
}
} /* myErrorHandler() */
/* main program entry point */
int main( void )
{
/* automatic variables for instances */
ArisErrorRec Error;
ArisPlatform hPlatform = NULL;
ArisServer hServer = NULL;
ArisMethod hMethod = NULL;
ArisDatabase hDatabase = NULL;
ArisGroup hGroup = NULL;
ArisModel hModel = NULL;
/* automatic variables for keys */
ArisPlatformKey PKey = ARIS_NOKEY;
ArisChar SKey [_MAX_SERVER];
ArisChar DbKey [_MAX_DATABASE];
ArisLanguageKey LKey = 1033; /* locale id */
ArisChar CKey [_MAX_CONFIG_KEY];
ArisGroupKey GKey = ARIS_NOKEY;
ArisModelKey MKey = ARIS_NOKEY;
/* automatic variables for strings */
ArisChar szVersion [_MAX_VERSION];
ArisChar szText [255];
/* regularise the global error handling function */
ArisErrorHandlerSet( myErrorHandler );
/* show the version of the ARIS Repository API */
printf( "Library: %s\n\n", ArisApiGetVersion( szVersion, _MAX_VERSION ) );
/* initialize the first (and only) ARIS platform */
hPlatform = ArisPlatformCreate( &Error );
PKey = ArisPlatformGetFirst( hPlatform, &Error );
ArisPlatformInit( hPlatform, PKey, &Error );
/* show all ARIS servers registered at the local machine */
hServer = ArisServerCreate( hPlatform, &Error );
printf( "%d server(s) found:\n", ArisServerGetCount( hPlatform, &Error ) );
for( ArisServerGetFirst( hPlatform, SKey, sizeof( SKey ), &Error );
!ArisErrorGetNum( &Error );
ArisServerGetNext ( hPlatform, SKey, sizeof( SKey ), &Error ) ) {
printf( " %s\n", SKey );
}
/* ask for the server to be initialized */
printf( "\nPlease enter a valid server name: "); SKey[0] = '\0';
scanf( "%s", SKey );
/* the specified server will be initialized */
printf( "Initializing server '%s'...\n\n", SKey );
ArisServerInit( hServer, SKey, &Error );
ArisServerLogin( hServer, &Error );
/* try to initialize the english ARIS method,
otherwise use the installed ARIS language */
hMethod = ArisMethodCreate( hServer, &Error );
ArisMethodInit( hMethod, "en", &Error );
/* show all available ARIS databases */
hDatabase = ArisDatabaseCreate( hServer, &Error );
printf( "%d database(s) found:\n", ArisDatabaseGetCount( hServer, &Error ) );
for( ArisDatabaseGetFirst( hServer, DbKey, sizeof( DbKey ), &Error );
!ArisErrorGetNum( &Error );
ArisDatabaseGetNext ( hServer, DbKey, sizeof( DbKey ), &Error ) ) {
printf( " %s\n", DbKey );
}
/* ask for the database to be opened */
printf( "\nPlease enter a valid database name: "); DbKey[0] = '\0';
scanf( "%s", DbKey );
/* the specified database will be opened with system/manager default */
printf( "Initializing database '%s'...\n\n", DbKey );
ArisDatabaseInit( hDatabase, DbKey, &Error );
ArisDatabaseOpen( hDatabase, "Guest", "guest", OPEN_STANDARD, NULL, &Error );
/* the user default language will be initialized */
ArisLanguageInit( hDatabase, LKey, &Error );
printf( "Initializing language %s...\n\n", ArisLanguageGetName( hDatabase, szText, sizeof( szText ), &Error ) );
/*
* the configuration 'entire method' will be initialized.
*
* You can find all available filter GUIDs in the
* configuration wizard of the ARIS Toolset. The
* following GUID corresponds to the entire method.
*
*/
strcpy( CKey, "DD838074-AC29-11d4-85B8-00005A4053FF" );
printf( "Initializing configuration '%s'...\n\n", CKey );
ArisConfigInit( hDatabase, CKey, &Error );
/* show all available ARIS groups in the database */
hGroup = ArisGroupCreate( hDatabase, &Error );
printf( "%d group(s) found:\n", ArisGroupGetCount( hDatabase, &Error ) );
for( GKey = ArisGroupGetFirst( hDatabase, &Error );
!ArisErrorGetNum( &Error );
GKey = ArisGroupGetNext ( hDatabase, &Error ) ) {
ArisGroupInit( hGroup, GKey, &Error );
printf( " %s\n", ArisGroupGetAttr( hGroup, AT_NAME, szText, sizeof( szText ), &Error ) );
}
/* show all available ARIS models in the several groups */
hModel = ArisModelCreate( hDatabase, &Error );
for( GKey = ArisGroupGetFirst( hDatabase, &Error );
!ArisErrorGetNum( &Error );
GKey = ArisGroupGetNext ( hDatabase, &Error ) ) {
ArisGroupInit( hGroup, GKey, &Error );
printf( "\n%d model(s) found in group '%s':\n", ArisModelGetCount( hGroup, &Error ),
ArisGroupGetAttr( hGroup, AT_NAME, szText, sizeof( szText ), &Error ) );
/* show all ARIS models in the current group */
for( MKey = ArisModelGetFirst( hGroup, &Error );
!ArisErrorGetNum( &Error );
MKey = ArisModelGetNext ( hGroup, &Error ) ) {
ArisModelInit( hModel, MKey, &Error );
printf( " %s\n", ArisModelGetAttr( hModel, AT_NAME, szText, sizeof( szText ), &Error ) );
}
}
/* deinitialize all objects and free all memory allocated by ArisXxxCreate() */
ArisModelFree ( &hModel , &Error );
ArisGroupFree ( &hGroup , &Error );
ArisDatabaseClose( hDatabase, &Error );
ArisDatabaseFree ( &hDatabase, &Error );
ArisMethodFree ( &hMethod , &Error );
ArisServerLogout ( hServer , &Error );
ArisServerFree ( &hServer , &Error );
ArisPlatformFree ( &hPlatform, &Error );
return EXIT_SUCCESS;
} /* main() */
/* end of file step04.c */die ersten Zeilen des Programmes sind:
Code: Alles auswählen
#ArisApi = 0
Ergebnis = OpenConsole()
If OpenLibrary(#ArisApi, "ATSApi.dll")
PrintN("Geoeffnet")
Else
PrintN("Konnte diese bloede Dll nicht oeffnen")
EndIf
PrintN("Oeffne ArisPlatformCreate")
hPlatform = CallFunction(#ArisApi, "ArisPlatformCreate" ,Error)
If CallFunction(#ArisApi, "ArisPlatformGetFirst", hPlatform, Error )
PrintN("hallo1")
PrintN("Oeffne ArisPlatformGetFirst")
PKey = CallFunction(#ArisApi, "ArisPlatformGetFirst", @hPlatform, Error )
EndIf
PrintN("Hello again")
CallFunction(#ArisApi, "ArisPlatformInit", hPlatform, PKey, Error)
PrintN("Hallo")
hServer.l = CallFunction(#ArisApi, "ArisServerCreate", hPlatform, Error)
PrintN(Str(hServer))
PrintN("CreateServer: "+Str(Error))
CallFunction(#ArisApi, "ArisServerInit", hServer, "servername.net", Error)
PrintN(Str(Error))Was mache ich bloß falsch?
Edit by NicTheQuick: Code-Tags gesetzt