CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Apr 2004
    Posts
    265

    INI file and UserProfile

    Hi,

    Is there a way to manually store a value to get the user profile path of a user in the INI file?

    Thanks

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: INI file and UserProfile

    What INI file are you talking about? If you want to just get the current user's profile path why not use the environment variable %UserProfile%.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Apr 2004
    Posts
    265

    Re: INI file and UserProfile

    Yes, I would like to know if this variable can be used in the INI file? For example, I need a string as follows:

    "Q:\test;%UserProfile%\Application Data"

    Can this be accomplished?

    Thanks

  4. #4
    Join Date
    May 2002
    Posts
    10,943

    Re: INI file and UserProfile

    I repeat my questions. You keep saying "the INI file"...What INI file are you talking about?

    Second, any modern programming language can just plain read environment variables. If you just would use the environment variable %UserProfile%, you would have no reason to access any INI file.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  5. #5
    Join Date
    Apr 2004
    Posts
    265

    Re: INI file and UserProfile

    I agree with you that %UserProfile% would read the user profile. But I need to get a set of paths at one stretch in a particular order as follows

    Path = Q:\test;C:\Documents and Settings\shers\test;.......

    where Q is a network drive.

    Thanks

  6. #6
    Join Date
    May 2002
    Posts
    10,943

    Re: INI file and UserProfile

    So why don't you just concatenate the string by using %UserProfile% plus the other parts? The language in which you plan to write this will affect how you obtain the user profile variable, but the rest is basic to programming.

    Code:
    path = "Q:\test;" & userProfile & "\test;......."
    Last edited by PeejAvery; February 8th, 2009 at 08:43 AM.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  7. #7
    Join Date
    Apr 2004
    Posts
    265

    Re: INI file and UserProfile

    I tried that too. But it takes the whole string as string.

  8. #8
    Join Date
    May 2002
    Posts
    10,943

    Re: INI file and UserProfile

    Quote Originally Posted by shers
    But it takes the whole string as string.
    What? That sentence makes no sense.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  9. #9
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: INI file and UserProfile


  10. #10
    Join Date
    Mar 2007
    Posts
    155

    Re: INI file and UserProfile

    Quote Originally Posted by PeejAvery View Post
    Second, any modern programming language can just plain read environment variables. If you just would use the environment variable %UserProfile%, you would have no reason to access any INI file.
    I don't understand how it will expand. Please show me what I am not getting. I think it is ExpandEnvironmentStrings API to do this job

  11. #11
    Join Date
    Jul 2008
    Posts
    24

    Re: INI file and UserProfile

    You can store anything you want too in an ini file. If this data is sensitive then you would have to encrypt it so users can't read it and copy it.

    Ini files don't have to be your.ini they can be any file extension you want to use providing it doesn't clash with the other extension registered to Windows. It could be your.dll and it could be padded out with any rubbish just to make the filesize to a small dll size rather that a few Kb.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured