Pfad zum eigenen Programm ermittln

Hi,

ich muß ein Programm abändern, welches in Visual C++ geschrieben wurde. Dort ist ein Pfad enthalten, der auf eine wichtige Datei zugreift.
sieht so aus:

Prf.Open ( „D:/Programme/MeinProgramm/programm.ini“);

Wie kann ich jetzt statt dem ganzen Pfad „D:/Programme/MeinProgramm/“ automatisch den Pfad des Programms angeben? Ich hab keine Ahnung von C++ !! Bitte schreibt mit die Syntax. Oder reicht es den Pfad wegzulassen?

Danke !

hi,

müsste mit der Funktion Paramstr(); gehn
einfach den Paramstr von 0 nehmen,der enthält den Programmfad,des ausführenden programm

grüsse
Sven.

Danke, funzt so aber nicht…

Prf.Open ( Paramstr(0) + „Datei.ini“);

Oder wie???

Muß man noch eine Headdatei dafür einbinden?

Hier ein Auszug aus MSDN…vielleicht hilfts…
_getdcwd, _wgetdcwd

Get full path name of current working directory on the specified drive.

char *_getdcwd( int drive, char *buffer, int maxlen );

wchar_t *_wgetdcwd( int drive, wchar_t *buffer, int maxlen );

Routine Required Header Compatibility
_getdcwd Win 95, Win NT
_wgetdcwd or Win NT

For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version

Return Value

Each of these functions returns buffer. A NULL return value indicates an error, and errno is set either to ENOMEM, indicating that there is insufficient memory to allocate maxlen bytes (when a NULL argument is given as buffer), or to ERANGE, indicating that the path is longer than maxlen characters.

Parameters

drive

Disk drive

buffer

Storage location for path

maxlen

Maximum length of path

Remarks

The _getdcwd function gets the full path of the current working directory on the specified drive and stores it at buffer. An error occurs if the length of the path (including the terminating null character) exceeds maxlen. The drive argument specifies the drive (0 = default drive, 1 = A, 2 = B, and so on). The buffer argument can be NULL; a buffer of at least size maxlen (more only if necessary) will automatically be allocated, using malloc, to store the path. This buffer can later be freed by calling free and passing it the _getdcwd return value (a pointer to the allocated buffer).

_getdcwd returns a string that represents the path of the current working directory. If the current working directory is set to the root, the string ends with a backslash ( \ ). If the current working directory is set to a directory other than the root, the string ends with the name of the directory and not with a backslash.

_wgetdcwd is a wide-character version of _getdcwd; the buffer argument and return value of _wgetdcwd are wide-character strings. _wgetdcwd and _getdcwd behave identically otherwise.

Generic-Text Routine Mappings

TCHAR.H Routine _UNICODE & _MBCS Not Defined _MBCS Defined _UNICODE Defined
_tgetdcwd _getdcwd _getdcwd _wgetdcwd

Example

/* GETDRIVE.C illustrates drive functions including:
* _getdrive _chdrive _getdcwd
*/

#include
#include
#include
#include
#include

void main( void )
{
int ch, drive, curdrive;
static char path[_MAX_PATH];

/* Save current drive. */
curdrive = _getdrive();

printf( „Available drives are: \n“ );

/* If we can switch to the drive, it exists. */
for( drive = 1; drive

ohh, gott!!!
Vielen Dank, das sieht so aus als würde es mir helfen. Ich werde es dann mal versuchen…

Aber ist das nicht etwas viel??? In anderen Sprachen sind es eine Zeile !

Danke!