FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
sys_getexepath.c
Go to the documentation of this file.
1
/* get the executable path */
2
3
#include "../fb.h"
4
#include <windows.h>
5
6
char
*
fb_hGetExePath
(
char
*dst, ssize_t maxlen )
7
{
8
GetModuleFileName( GetModuleHandle(
NULL
), dst, maxlen );
9
10
char
*
p
= strrchr( dst,
'\\'
);
11
if
( p !=
NULL
)
12
*p =
'\0'
;
13
else
14
dst[0] =
'\0'
;
15
16
/* just a drive letter? make sure \ follows to prevent using relative path */
17
if
( maxlen > 3 && dst[2] ==
'\0'
&& dst[1] ==
':'
)
18
{
19
if
( (dst[0] & ~32) >=
'A'
&& (dst[0] & ~32) <=
'Z'
)
20
{
21
dst[2] =
'\\'
;
22
dst[3] =
'\0'
;
23
}
24
}
25
26
return
p
;
27
}
rtlib
win32
sys_getexepath.c
Generated on Thu Jan 23 2014 19:40:10 for FreeBASIC by
1.8.4