CreateFile

Hi all,
Iam sending the string “C:\myfile.txt” from my application folder.Is it
correct to pass this string as a PWCSTR in RtlInitUnicodeString.But Iam
getting the createFile failed status.Please help me.

Thanks&Regards
sobana.D

Use “\\.\c:\myfile.txt”.

Cheers
Kiran

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Sobana
Sent: Wednesday, May 26, 2004 9:55 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] CreateFile

Hi all,
Iam sending the string “C:\myfile.txt” from my application folder.Is
it
correct to pass this string as a PWCSTR in RtlInitUnicodeString.But Iam
getting the createFile failed status.Please help me.

Thanks&Regards
sobana.D


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@wipro.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

  • Use it as following , that makes simple…
    RtlInitUnicodeString(,L"C:\myfile.txt")

    Further…this is assuming that ur code fails during the unicode-string initialization.
    If u need more clarification, then u have to post bit more details of when exactly its failing on which scenario.etc…

    Good luck…

    Regards…
    K.Raju

    -----Original Message-----
    From: Sobana [mailto:xxxxx@qmaxtech.com]
    Sent: Wednesday, May 26, 2004 9:55 AM
    To: Windows System Software Devs Interest List
    Subject: [ntdev] CreateFile

    Hi all,
    Iam sending the string “C:\myfile.txt” from my application folder.Is it
    correct to pass this string as a PWCSTR in RtlInitUnicodeString.But Iam
    getting the createFile failed status.Please help me.

    Thanks&Regards
    sobana.D


    Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

    You are currently subscribed to ntdev as: xxxxx@inquesttechnologies.com
    To unsubscribe send a blank email to xxxxx@lists.osr.com

… Try this sample… …

void OpenFileExample (void)
{
HANDLE hFile;

hFile = CreateFile (TEXT(“”\\?\c:\myfile.txt""),
GENERIC_READ, // Open for reading
FILE_SHARE_READ, // Share for reading
NULL, // No security
OPEN_ALWAYS, // Opens if exists else creates new file
FILE_ATTRIBUTE_NORMAL, // Normal file
NULL); // No template file

if (hFile == INVALID_HANDLE_VALUE)
{
// Your error-handling code goes here.
return;
}
} // End of OpenFileExample code

==================================
Regards
M.C.Krishnama Raju

-----Original Message-----
From: Krishnama Raju
Sent: Wednesday, May 26, 2004 10:26 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] CreateFile

  • Use it as following , that makes simple…
    RtlInitUnicodeString(,L"C:\myfile.txt")

    Further…this is assuming that ur code fails during the unicode-string initialization.
    If u need more clarification, then u have to post bit more details of when exactly its failing on which scenario.etc…

    Good luck…

    Regards…
    K.Raju

    -----Original Message-----
    From: Sobana [mailto:xxxxx@qmaxtech.com]
    Sent: Wednesday, May 26, 2004 9:55 AM
    To: Windows System Software Devs Interest List
    Subject: [ntdev] CreateFile

    Hi all,
    Iam sending the string “C:\myfile.txt” from my application folder.Is it
    correct to pass this string as a PWCSTR in RtlInitUnicodeString.But Iam
    getting the createFile failed status.Please help me.

    Thanks&Regards
    sobana.D


    Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

    You are currently subscribed to ntdev as: xxxxx@inquesttechnologies.com
    To unsubscribe send a blank email to xxxxx@lists.osr.com


    Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

    You are currently subscribed to ntdev as: xxxxx@inquesttechnologies.com
    To unsubscribe send a blank email to xxxxx@lists.osr.com