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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. GetPrivateProfileString() problem

GetPrivateProfileString() problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 Posts 2 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.
  • A Offline
    A Offline
    ashish8patil
    wrote on last edited by
    #1

    What is woring in my following codes run time error is occuring for both code int main() {LPTSTR strResult; LPTSTR strDefault=L"no"; DWORD d=255; GetPrivateProfileString(L"data",L"Patchcab ", strDefault,strResult,d, L"D:\\TMP\\patchpolicy.ini"); printf("%s",strResult); } int main() { LPTSTR strResult=L""; LPTSTR strDefault=L"no"; DWORD d=255; GetPrivateProfileString(L"data",L"Patchcab ",strDefault,strResult ,d,L"D:\\TMP\\patchpolicy.ini"); printf("%s",strResult); }

    _ 1 Reply Last reply
    0
    • A ashish8patil

      What is woring in my following codes run time error is occuring for both code int main() {LPTSTR strResult; LPTSTR strDefault=L"no"; DWORD d=255; GetPrivateProfileString(L"data",L"Patchcab ", strDefault,strResult,d, L"D:\\TMP\\patchpolicy.ini"); printf("%s",strResult); } int main() { LPTSTR strResult=L""; LPTSTR strDefault=L"no"; DWORD d=255; GetPrivateProfileString(L"data",L"Patchcab ",strDefault,strResult ,d,L"D:\\TMP\\patchpolicy.ini"); printf("%s",strResult); }

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      There is no memory allocated for the LpReturnedString parameter. You're declaring it as LPTSTR strResult which is only a pointer. You will need to do this -

      TCHAR strResult[255];
      DWORD d = 255;

      Also change printf to _tprintf.

      «_Superman_» I love work. It gives me something to do between weekends.

      A 1 Reply Last reply
      0
      • _ _Superman_

        There is no memory allocated for the LpReturnedString parameter. You're declaring it as LPTSTR strResult which is only a pointer. You will need to do this -

        TCHAR strResult[255];
        DWORD d = 255;

        Also change printf to _tprintf.

        «_Superman_» I love work. It gives me something to do between weekends.

        A Offline
        A Offline
        ashish8patil
        wrote on last edited by
        #3

        thanks a lot.

        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