<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://performiq.com/kb/index.php?action=history&amp;feed=atom&amp;title=Create_Unique_File_Name_in_Windows</id>
	<title>Create Unique File Name in Windows - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://performiq.com/kb/index.php?action=history&amp;feed=atom&amp;title=Create_Unique_File_Name_in_Windows"/>
	<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=Create_Unique_File_Name_in_Windows&amp;action=history"/>
	<updated>2026-05-18T13:52:27Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>https://performiq.com/kb/index.php?title=Create_Unique_File_Name_in_Windows&amp;diff=3344&amp;oldid=prev</id>
		<title>PeterHarding at 06:21, 6 January 2011</title>
		<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=Create_Unique_File_Name_in_Windows&amp;diff=3344&amp;oldid=prev"/>
		<updated>2011-01-06T06:21:42Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:21, 6 January 2011&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l140&quot;&gt;Line 140:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 140:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Visual Studio]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Visual Studio]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Windows Development]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>PeterHarding</name></author>
	</entry>
	<entry>
		<id>https://performiq.com/kb/index.php?title=Create_Unique_File_Name_in_Windows&amp;diff=2463&amp;oldid=prev</id>
		<title>PeterHarding: CReate Unique File Name in Windows moved to Create Unique File Name in Windows: Type</title>
		<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=Create_Unique_File_Name_in_Windows&amp;diff=2463&amp;oldid=prev"/>
		<updated>2008-07-21T03:33:02Z</updated>

		<summary type="html">&lt;p&gt;&lt;a href=&quot;/kb/index.php/CReate_Unique_File_Name_in_Windows&quot; class=&quot;mw-redirect&quot; title=&quot;CReate Unique File Name in Windows&quot;&gt;CReate Unique File Name in Windows&lt;/a&gt; moved to &lt;a href=&quot;/kb/index.php/Create_Unique_File_Name_in_Windows&quot; title=&quot;Create Unique File Name in Windows&quot;&gt;Create Unique File Name in Windows&lt;/a&gt;: Type&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 13:33, 21 July 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>PeterHarding</name></author>
	</entry>
	<entry>
		<id>https://performiq.com/kb/index.php?title=Create_Unique_File_Name_in_Windows&amp;diff=2461&amp;oldid=prev</id>
		<title>PeterHarding: New page: =Example=    * See : http://msdn.microsoft.com/en-us/library/aa363875(VS.85).aspx   &lt;pre&gt; #include &lt;windows.h&gt; #include &lt;tchar.h&gt; #include &lt;stdio.h&gt;  #define BUFSIZE 512  int _tmain(int ar...</title>
		<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=Create_Unique_File_Name_in_Windows&amp;diff=2461&amp;oldid=prev"/>
		<updated>2008-07-21T03:18:43Z</updated>

		<summary type="html">&lt;p&gt;New page: =Example=    * See : http://msdn.microsoft.com/en-us/library/aa363875(VS.85).aspx   &amp;lt;pre&amp;gt; #include &amp;lt;windows.h&amp;gt; #include &amp;lt;tchar.h&amp;gt; #include &amp;lt;stdio.h&amp;gt;  #define BUFSIZE 512  int _tmain(int ar...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=Example=&lt;br /&gt;
&lt;br /&gt;
  * See : http://msdn.microsoft.com/en-us/library/aa363875(VS.85).aspx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#include &amp;lt;windows.h&amp;gt;&lt;br /&gt;
#include &amp;lt;tchar.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#define BUFSIZE 512&lt;br /&gt;
&lt;br /&gt;
int _tmain(int argc, TCHAR *argv[])&lt;br /&gt;
{&lt;br /&gt;
    HANDLE hFile;&lt;br /&gt;
    HANDLE hTempFile; &lt;br /&gt;
    DWORD dwRetVal;&lt;br /&gt;
    DWORD dwBytesRead;&lt;br /&gt;
    DWORD dwBytesWritten; &lt;br /&gt;
    DWORD dwBufSize=BUFSIZE;&lt;br /&gt;
    UINT uRetVal;&lt;br /&gt;
    TCHAR szTempName[BUFSIZE];  &lt;br /&gt;
    char buffer[BUFSIZE]; &lt;br /&gt;
    TCHAR lpPathBuffer[BUFSIZE];&lt;br /&gt;
    BOOL fSuccess;&lt;br /&gt;
&lt;br /&gt;
    if(argc != 2)&lt;br /&gt;
    {&lt;br /&gt;
        _tprintf(TEXT(&amp;quot;Usage: %s &amp;lt;file&amp;gt;\n&amp;quot;), argv[0]);&lt;br /&gt;
        return -1;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Open the existing file. &lt;br /&gt;
    hFile = CreateFile(argv[1],               // file name &lt;br /&gt;
                       GENERIC_READ,          // open for reading &lt;br /&gt;
                       0,                     // do not share &lt;br /&gt;
                       NULL,                  // default security &lt;br /&gt;
                       OPEN_EXISTING,         // existing file only &lt;br /&gt;
                       FILE_ATTRIBUTE_NORMAL, // normal file &lt;br /&gt;
                       NULL);                 // no template &lt;br /&gt;
    if (hFile == INVALID_HANDLE_VALUE) &lt;br /&gt;
    { &lt;br /&gt;
        printf (&amp;quot;First CreateFile failed (%d)\n&amp;quot;, GetLastError());&lt;br /&gt;
        return (1);&lt;br /&gt;
    } &lt;br /&gt;
&lt;br /&gt;
     // Get the temp path.&lt;br /&gt;
    dwRetVal = GetTempPath(dwBufSize,     // length of the buffer&lt;br /&gt;
                           lpPathBuffer); // buffer for path &lt;br /&gt;
    if (dwRetVal &amp;gt; dwBufSize || (dwRetVal == 0))&lt;br /&gt;
    {&lt;br /&gt;
        printf (&amp;quot;GetTempPath failed (%d)\n&amp;quot;, GetLastError());&lt;br /&gt;
        return (2);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Create a temporary file. &lt;br /&gt;
    uRetVal = GetTempFileName(lpPathBuffer, // directory for tmp files&lt;br /&gt;
                              TEXT(&amp;quot;NEW&amp;quot;),  // temp file name prefix &lt;br /&gt;
                              0,            // create unique name &lt;br /&gt;
                              szTempName);  // buffer for name &lt;br /&gt;
    if (uRetVal == 0)&lt;br /&gt;
    {&lt;br /&gt;
        printf (&amp;quot;GetTempFileName failed (%d)\n&amp;quot;, GetLastError());&lt;br /&gt;
        return (3);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Create the new file to write the upper-case version to.&lt;br /&gt;
    hTempFile = CreateFile((LPTSTR) szTempName, // file name &lt;br /&gt;
                           GENERIC_READ | GENERIC_WRITE, // open r-w &lt;br /&gt;
                           0,                    // do not share &lt;br /&gt;
                           NULL,                 // default security &lt;br /&gt;
                           CREATE_ALWAYS,        // overwrite existing&lt;br /&gt;
                           FILE_ATTRIBUTE_NORMAL,// normal file &lt;br /&gt;
                           NULL);                // no template &lt;br /&gt;
    if (hTempFile == INVALID_HANDLE_VALUE) &lt;br /&gt;
    { &lt;br /&gt;
        printf (&amp;quot;Second CreateFile failed (%d)\n&amp;quot;, GetLastError());&lt;br /&gt;
        return (4);&lt;br /&gt;
    } &lt;br /&gt;
&lt;br /&gt;
    // Read BUFSIZE blocks to the buffer. Change all characters in &lt;br /&gt;
    // the buffer to upper case. Write the buffer to the temporary &lt;br /&gt;
    // file. &lt;br /&gt;
    do &lt;br /&gt;
    {&lt;br /&gt;
        if (ReadFile(hFile, &lt;br /&gt;
                     buffer, &lt;br /&gt;
                     BUFSIZE, &lt;br /&gt;
                     &amp;amp;dwBytesRead, &lt;br /&gt;
                     NULL)) &lt;br /&gt;
        { &lt;br /&gt;
            CharUpperBuffA(buffer, dwBytesRead); &lt;br /&gt;
            fSuccess = WriteFile(hTempFile, &lt;br /&gt;
                                 buffer, &lt;br /&gt;
                                 dwBytesRead,&lt;br /&gt;
                                 &amp;amp;dwBytesWritten, &lt;br /&gt;
                                 NULL); &lt;br /&gt;
            if (!fSuccess) &lt;br /&gt;
            {&lt;br /&gt;
                printf (&amp;quot;WriteFile failed (%d)\n&amp;quot;, GetLastError());&lt;br /&gt;
                return (5);&lt;br /&gt;
            }&lt;br /&gt;
        } &lt;br /&gt;
        else&lt;br /&gt;
        {&lt;br /&gt;
            printf (&amp;quot;ReadFile failed (%d)\n&amp;quot;, GetLastError());&lt;br /&gt;
            return (6);&lt;br /&gt;
        }&lt;br /&gt;
    } while (dwBytesRead == BUFSIZE); &lt;br /&gt;
&lt;br /&gt;
    // Close the handles to the files.&lt;br /&gt;
    fSuccess = CloseHandle (hFile);&lt;br /&gt;
    if (!fSuccess) &lt;br /&gt;
    {&lt;br /&gt;
       printf (&amp;quot;CloseHandle failed (%d)\n&amp;quot;, GetLastError());&lt;br /&gt;
       return (7);&lt;br /&gt;
    }&lt;br /&gt;
    fSuccess = CloseHandle (hTempFile);&lt;br /&gt;
    if (!fSuccess) &lt;br /&gt;
    {&lt;br /&gt;
       printf (&amp;quot;CloseHandle failed (%d)\n&amp;quot;, GetLastError());&lt;br /&gt;
       return (8);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Move the temporary file to the new text file.&lt;br /&gt;
    fSuccess = MoveFileEx(szTempName, &lt;br /&gt;
                          TEXT(&amp;quot;Allcaps.txt&amp;quot;), &lt;br /&gt;
                          MOVEFILE_REPLACE_EXISTING);&lt;br /&gt;
    if (!fSuccess)&lt;br /&gt;
    { &lt;br /&gt;
        printf (&amp;quot;MoveFileEx failed (%d)\n&amp;quot;, GetLastError());&lt;br /&gt;
        return (9);&lt;br /&gt;
    }&lt;br /&gt;
    else &lt;br /&gt;
        _tprintf(TEXT(&amp;quot;All caps version of %s written to Allcaps.txt\n&amp;quot;), argv[1]);&lt;br /&gt;
    return (0);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Visual Studio]]&lt;/div&gt;</summary>
		<author><name>PeterHarding</name></author>
	</entry>
</feed>