티스토리 뷰
반응형
#include <Windows.h>
#include <string>
int main()
{
// Open a handle to the file
HANDLE hFile = CreateFile(
L"C:\\NewFile.txt", // Filename
GENERIC_WRITE, // Desired access
FILE_SHARE_READ, // Share mode
NULL, // Security attributes
CREATE_NEW, // Creates a new file, only if it doesn't already exist
FILE_ATTRIBUTE_NORMAL, // Flags and attributes
NULL); // Template file handle
if (hFile == INVALID_HANDLE_VALUE)
{
// Failed to open/create file
return 2;
}
// Write data to the file
std::string strText = "Hello World!"; // For C use LPSTR (char*) or LPWSTR (wchar_t*)
DWORD bytesWritten;
WriteFile(
hFile, // Handle to the file
strText.c_str(), // Buffer to write
strText.size(), // Buffer size
&bytesWritten, // Bytes written
nullptr); // Overlapped
// Close the handle once we don't need it.
CloseHandle(hFile);
}
반응형
'프로그래밍' 카테고리의 다른 글
Python Struct 사용해보기 예제 (0) | 2023.01.20 |
---|---|
python으로 http 요청 보내기 예제 (0) | 2023.01.20 |
winapi 쓰레드 생성하기 (0) | 2022.01.27 |
winapi 프로세스 생성, exit code 확인하기 (0) | 2022.01.27 |
스핀락을 사용하는 지원 루틴 호출 (0) | 2020.03.02 |
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- Python
- 파이썬
- react
- 유튜브
- 예제
- CSS
- 생각
- 주식
- JSX
- Frontend
- ChatGPT
- frida
- go
- 투자
- WinAPI
- JavaScript
- Spring
- 스핀락
- Backend
- reactjs
- HTML
- Java
- 트렌드
- Linux
- ios
- 부동산
- 커널드라이버
- SWiFT
- golang
- Windows
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함