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 32 33 34 35 36 37
|
#include <windows.h>
#include <stdio.h>
#include <string>
const char* c_str();
using namespace std;
char RandomFileName()
{
srand(GetTickCount());//Seeeeeeed
const char *letter[] = { "a","b","c","d","e","f","g","h","i","j","k","l","m","n",
"o","p","q","r","s","t","u","v","w","x","y","z","1","2",
"3","4","5","6","7","8","9","9", 0 };//Chars to randomize
char filename[MAX_PATH]="";
int rnd;
int length=0;
for(;;)//Infinte Loop
{
rnd = rand() % 36;// The amount of chars to randomize
strcat(filename,letter[rnd]);//Bind the random char to the buffer
if(strlen(filename)==12)//Adjust this for a bigger or smaller filename
{
strcat(filename,".bmp");//Bind ".bmp" onto the finshed product
break;//Escape the loop
}
length++;//Add more chars if not finished
}
return *filename;
}
|