Last active
August 29, 2015 14:07
-
-
Save k-takata/e79e99b7525857dd6214 to your computer and use it in GitHub Desktop.
Create a very long file name with ANSI API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
main(int argc, char *argv[]) | |
{ | |
char *filename = "あいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえおあいうえお.txt"; | |
HANDLE h; | |
h = CreateFileA(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); | |
printf("handle:%p, length:%d\n", h, strlen(filename)); | |
CloseHandle(h); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The length of
filename
is:It is obvious that the length is longer then
MAX_PATH
(=260) bytes, butCreateFileA
does create the file.Why
CreateFileA
can handle a filename which is longer thanMAX_PATH
bytes?