{"id":4653,"date":"2014-03-30T14:19:16","date_gmt":"2014-03-30T14:19:16","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-to-create-a-file-using-windows-api-collection-of-common-programming-errors\/"},"modified":"2014-03-30T14:19:16","modified_gmt":"2014-03-30T14:19:16","slug":"how-to-create-a-file-using-windows-api-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-to-create-a-file-using-windows-api-collection-of-common-programming-errors\/","title":{"rendered":"how to create a file using windows API?-Collection of common programming errors"},"content":{"rendered":"<p><code>LPCTSTR<\/code> is the same as <code>const TCHAR*<\/code> (&#8220;Long Pointer to a Constant <code>TCHAR<\/code>-String&#8221;), which is either <code>const wchar_t*<\/code> or <code>const char*<\/code> depending on the character set. So just pass in a string surrounded by <code>_T()<\/code>, like:<\/p>\n<pre><code>CreateFile(_T(\"C:\\\\File.txt\"), FILE_READ_DATA, FILE_SHARE_READ,\n    NULL, OPEN_ALWAYS, 0, NULL);\n<\/code><\/pre>\n<p>(By the way, <code>FILE<\/code> is not part of the Windows SDK; it&#8217;s part of the standard C runtime library, and it&#8217;s internally <em>based<\/em> on <code>CreateFile<\/code>, which creates a file based on its name.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>LPCTSTR is the same as const TCHAR* (&#8220;Long Pointer to a Constant TCHAR-String&#8221;), which is either const wchar_t* or const char* depending on the character set. So just pass in a string surrounded by _T(), like: CreateFile(_T(&#8220;C:\\\\File.txt&#8221;), FILE_READ_DATA, FILE_SHARE_READ, NULL, OPEN_ALWAYS, 0, NULL); (By the way, FILE is not part of the Windows SDK; it&#8217;s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4653","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4653","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4653"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4653\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4653"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4653"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4653"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}