Chciałbym stworzyć plik tekstowy na pulpicie osoby, która uruchamia program, a następnie wydrukować go. Mój problem polega na tym, że nie mogę stworzyć pliku i nie wiem jak się zabrać za drukowanie. W textboxie wypisałem sobie adres uchwytu na plik i wydaje mi się, że taki nie powinien być. Oto kod który mam:
SHGetFolderPath(NULL,CSIDL_DESKTOP,
NULL,
0,
szPath);
sprintf(szPath,"%s%s",szPath,"\\Nowy.txt");
hFile= CreateFile(
szPath, // pointer to name of the file
DWORD GENERIC_WRITE, // access (read-write) mode
0, // share mode
(LPSECURITY_ATTRIBUTES)CREATE_ALWAYS, // pointer to security descriptor
FILE_ATTRIBUTE_NORMAL, // how to create
0, // file attributes
0 // handle to file with attributes to copy
);
sprintf(szPath,"%x",hFile);
hwndChild = CreateWindowEx (0, (LPCSTR)"EDIT",
(LPCSTR)szPath,
WS_CHILD | WS_VISIBLE |
WS_BORDER,
cxChar, cyChar,
200, 40,
hwnd, (HMENU) 6,
((LPCREATESTRUCT) lParam)->hInstance,
NULL) ;
Napisałem w tym temacie, ponieważ to jest .NET i z c++ ma mniej wspólnego.