locked
write file inside UMD driver for win8 style application

    Question

  • Hi,

    I have a user mode driver (to be clear, it is WDDM1.2 UMD), written with c, which can be called by desktop style application and win8 style application.

    I want to write something into a log file inside the user mode driver when it is called by the win8 style application, but failed.  See the key code below:

    FILE* fp;
    fopen_s(&fp, "tracexyz.log", "wt");  //also tried such as "c:\\temp\\tracexyz.log" and "d:\\temp\\tracexyz.log"
    if (fp != NULL)  //fp is always NULL
    {
        fclose(fp);
    }

    I have disabled UAC, and also tried to make everyone have the full control of c:\temp and d:\temp.  I also tried to use function CreateFile(filename, GENERIC_WRITE,  FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH, 0);

    All my tries do not work, could you help to let me which function i should use? thanks.

    • Moved by Jesse Jiang Wednesday, September 26, 2012 6:10 AM (From:Visual C++ Language)
    Tuesday, September 25, 2012 8:42 AM

All replies

  • btw, if it is called in a desktop style application, the above code works well.

    and GetLastError() returns 5 after function CreateFile for the win8 style application case.

    • Edited by csstud Tuesday, September 25, 2012 8:55 AM
    Tuesday, September 25, 2012 8:49 AM
  • Hi Csstud,

    Welcome here.

    According to your description, I'd like to move this thread to "Tailoring your Windows Store app for hardware and devices Forum" for better support.

    Thanks for your understanding and active participation in the MSDN Forum.

    Best regards,


    Elegentin Xie [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, September 26, 2012 6:14 AM
  • Hi,

    The CreateFile API is not supported in Windows Store app. You can check the document :
    Applies to: desktop apps only

    You can try to use CreateFile2 function instead of CreateFile API
    http://msdn.microsoft.com/en-us/library/windows/desktop/hh449422(v=vs.85).aspx 

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, September 26, 2012 6:15 AM
  • Thanks Jesse, I tried to use CreateFile2 but it failed to compile, i do have include windows.h at the beginning of .c file, and also tried to include FileAPI.h, still could not compile it.

    error C4013: 'CreateFile2' undefined; assuming extern returning int

    Thursday, September 27, 2012 3:16 AM