hi leute..
kann mir jemand sagen was ich hier falsch mache..?
über die windows shell bekomme den pfad über jene datei,
die der user anklickt..
ich möchte diesen pfad kürzen, damit ich nur noch das verzeichnis der datei habe..
zB:
C:\Spiele\MeinSpiel zu C:\Spiele\
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#include <windows.h>
LPWSTR getOperatingPath (LPWSTR full_path)
{
LPWSTR path = NULL;
size_t to = 0,
counter = wcslen(full_path);
while ( full_path[counter] != '\\' )
counter--;
to = wcslen(full_path) - (wcslen(full_path) - counter);
path = new wchar_t(to);
wcsncpy(path, full_path, to);
path[to] = '\0';
return path;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
size_t size = strlen(lpCmdLine) + 1;
LPWSTR path = new WCHAR(size),
operatingPath = new WCHAR(size);
MultiByteToWideChar(CP_ACP, NULL,
lpCmdLine, size,
path, size);
operatingPath = getOperatingPath(path);
CreateDirectory(operatingPath, NULL);
return 0;
}
|