Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CreateFile ... error C2065

CreateFile ... error C2065

Scheduled Pinned Locked Moved C / C++ / MFC
securityhelpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gunnar66
    wrote on last edited by
    #1

    Hi I try to Create a File. The LpFileName i will receive from a token. But i get and error when i do this, Why? Error : error C2065: 'Lfilnavn1' : undeclared identifier Here is some of the code: HANDLE hFile1; char seps[] = ","; char *token; int ch = ','; char* filnavn1; token = strtok((char *)lpCmdLine, seps ); filnavn1 = token; while( token != NULL ) { token = strtok( NULL, seps ); // Get all token and assign to strings } hFile1 = CreateFile (TEXT(filnavn1), // Open .txt GENERIC_READ, // Open for reading 0, // Do not share NULL, // No security OPEN_EXISTING, // Existing file only FILE_ATTRIBUTE_NORMAL, // Normal file NULL); // No template file

    P 1 Reply Last reply
    0
    • G gunnar66

      Hi I try to Create a File. The LpFileName i will receive from a token. But i get and error when i do this, Why? Error : error C2065: 'Lfilnavn1' : undeclared identifier Here is some of the code: HANDLE hFile1; char seps[] = ","; char *token; int ch = ','; char* filnavn1; token = strtok((char *)lpCmdLine, seps ); filnavn1 = token; while( token != NULL ) { token = strtok( NULL, seps ); // Get all token and assign to strings } hFile1 = CreateFile (TEXT(filnavn1), // Open .txt GENERIC_READ, // Open for reading 0, // Do not share NULL, // No security OPEN_EXISTING, // Existing file only FILE_ATTRIBUTE_NORMAL, // Normal file NULL); // No template file

      P Offline
      P Offline
      P Rex
      wrote on last edited by
      #2

      Hi, just declare your Lfilnavn1 or remove 'L' from filnavn1 in the line where you get this error! Then it should work P.

      G 1 Reply Last reply
      0
      • P P Rex

        Hi, just declare your Lfilnavn1 or remove 'L' from filnavn1 in the line where you get this error! Then it should work P.

        G Offline
        G Offline
        gunnar66
        wrote on last edited by
        #3

        You wrote : just declare your Lfilnavn1 or remove L from filnavn1! in the line where you get this error! I get this error in this line hFile1 = CreateFile (TEXT(filnavn1), // Open .txt GENERIC_READ, // Open for reading 0, // Do not share NULL, // No security OPEN_EXISTING, // Existing file only FILE_ATTRIBUTE_NORMAL, // Normal file NULL); // No template file As you can see i do not use Lfilenavn1 at all. It is the CreateFile who make the error So what could be wrong. It works in Visual C++, but not in Emededd C++ that I use.

        A 1 Reply Last reply
        0
        • G gunnar66

          You wrote : just declare your Lfilnavn1 or remove L from filnavn1! in the line where you get this error! I get this error in this line hFile1 = CreateFile (TEXT(filnavn1), // Open .txt GENERIC_READ, // Open for reading 0, // Do not share NULL, // No security OPEN_EXISTING, // Existing file only FILE_ATTRIBUTE_NORMAL, // Normal file NULL); // No template file As you can see i do not use Lfilenavn1 at all. It is the CreateFile who make the error So what could be wrong. It works in Visual C++, but not in Emededd C++ that I use.

          A Offline
          A Offline
          Antony M Kancidrowski
          wrote on last edited by
          #4

          The TEXT macro eventually translates to L What TEXT expects is a quoted string e.g. TEXT("myfile.txt") What you need to do is convert the char* filnavn1 to a wide char format string when using Embedded C++. Then use this as the first parameter in CreateFile Ant. I'm hard, yet soft.
          I'm coloured, yet clear.
          I'm fruity and sweet.
          I'm jelly, what am I? Muse on it further, I shall return!
          - David Walliams (Little Britain)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups