Jump to content

This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.

Unique Filename

7 replies to this topic


  • Members
  • 4 posts

Posted 06 March 2001 - 21:53

I have created an installation for a product that needs
to be backwardly compatible with older installations.
Unfortunately, the old installations were crudely done,
and now I need to check for the existance of a folder,
and if there, copy it to a new folder, uniquely named.
I thought I had a tool for this, but cannot seem to find
it. Ideally, I'd post-append some unique identifier on
the folder name. I'd need to be sure that the identifier
is unique, so the contents won't be overwritten

I'm not a C programmer, although I've dabbled in Visual C.
I'd like to avoid having to develop a DLL, if possible,
due to time constraints.  I'd like to use something like a
rand() function, but IS doesn't seem to provide anything
like it.

Does anyone have a suggestion?

Best Regards,


Stefan Krueger

Stefan Krueger


  • Administrators
  • 13,269 posts

Posted 06 March 2001 - 22:03

One way would be to use a number in the name, and make sure that it is unique (i.e. increment it until it is unique).
Another option would be a GUID, which is guaranteed to be globally unique. Such a string can be retrieved from ole32.dll, sample code is here on InstallSite under IS5/6 Samples -> Operating System -> Create GUID as String. The result will look something like this:


  • Members
  • 4 posts

Posted 06 March 2001 - 22:51

Thanks for the pointer.
I would LOVE to be able to post-append a number to
a filename, incrementing until it's unique, but I
know of no arithmetic functions inside installshield
to do the increment.  

Now, this seems unlikely that there is no arithmetic
function, so am I really blind?



  • Members
  • 4 posts

Posted 06 March 2001 - 23:41

Okay, so I guess I was blind.  After perusing
the docs more thoroughly, and in an attempt NOT to
look totally stupid, I see that I can add variables
like this

nNum3 = nNum1 + nNum2;

(from NumToStr example)


Thanks for your patience,



  • Members
  • 27 posts

Posted 07 March 2001 - 12:39

Why not use Windows API function GetTempFile()?


  • Members
  • 5 posts

Posted 07 March 2001 - 18:06

Hello Deb:
After doing program, I have a way to back up a filename with unique name.

Here is the source:
svFilePath //location for file
svTemp     //reserve to return value
svFile         //filename with extension file.
svExtension = "%03d"; // this is extension file
nValue = 0;
bDone = FALSE;
svFileName = "example."; // not include extension.
while (bDone = FALSE)
    sprintf(svTemp, svExtension, nValue);
    svFile = svFileName + svTemp;
    if FindFile(svFilePath, svFile,  svTemp) < 0 then
       bDone = TRUE;
    nValue = nValue + 1;

After exit the while loop, you will get the filename with the number increment in extension file.  For example, if you have filename "example.txt" in c:\temp, you will get the other file name is "example.000" after exit while loop and so on.

I think that can help you a little bit.


  • Members
  • 4 posts

Posted 07 March 2001 - 18:22

Thanks for posting your program with the incremental
numbering.  The one I came up with looks remarkably similar!


I sure do appreciate the help,