Hi,
I'm trying to open a file using the following code. However, I can't figure out how to get input from the user and either convert that string to a LPCWSTR or simply read the input as a LPCWSTR. Any suggestions?
Code:
HANDLE OpenFile(LPCWSTR FileName, DWORD AccessMode)
{
HANDLE FileHandle;
DWORD CreateAttribute;
CreateAttribute = (AccessMode == GENERIC_READ)?OPEN_EXISTING:CREATE_ALWAYS;
FileHandle = CreateFile(FileName, AccessMode, FILE_SHARE_READ, NULL, CreateAttribute, FILE_ATTRIBUTE_NORMAL, NULL);
return(FileHandle);
}
int main(int argc, char* argv[])
{
DWORD LengthIn, InFileSize, LengthOut, OutFileSize;
HGLOBAL FileDataPtr;
char infile[80];
char outfile[80];
printf("What's the input file? ");
scanf("%s", infile);
printf("\nWhat's the output file? ");
scanf("%s", outfile);
printf("What's the LevelMask:\n\nHCI=0x0001\nL2CAP=0x0002\nSDP=0x0004\nRFCOMM=0x0008\nOBEX=0x0010\nBNEP/PAN=0x0020\n");
printf("\nTo Do Multiple Parsing:\nLogical AND Packet Types (ex. for HCI and L2CAP -> 0x0003)\n ?");
scanf("%04X", &LevelMask);
printf("What's the DumpMask:\n\nHCI=0x0001\nL2CAP=0x0002\nSDP=0x0004\nRFCOMM=0x0008\nOBEX=0x0010\nBNEP/PAN=0x0020\n");
printf("\nTo Do Multiple Parsing:\nLogical AND Packet Types (ex. for HCI and L2CAP -> 0x0003)\n ?");
scanf("%04X", &DumpMask);
printf("%s %s 0x%04x 0x%04x\n", infile, outfile, LevelMask, DumpMask);
InFile = OpenFile(TEXT(infile), GENERIC_READ);
OutFile = OpenFile(TEXT(outfile), GENERIC_WRITE);
}
If I hard code in my input and output files, this code works. I'm not too familiar with using LPCWSTR's, so any help would be appreciated.