CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2001
    Posts
    13

    Help determining user

    What is the best way to have my program add an icon to the StartUp folder on the Start menu? Right now I am manually checking that folder to see if the shortcut already exists, if not, then create it. I am running into problems on Win2k however because the StartUp folder is under Documents and Settings\Username\Startup. Is there a way to determine which user is curently logged in? Or another way of adding an Icon to the StartUp folder? Thanks!

    Ryan


  2. #2
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: Help determining user

    There is an API call you can use:


    'Declaration
    Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (byval lpBuffer as string, nSize as Long) as Long



    That requres you to send it a preinitialised string buffer to use it...


    Dim sBuff as string, lRet as Long, lLen as long

    sBuff = string$(1024,0)
    lLen = len(sBuff)

    lRet = GetUsername(sBuff, lLen)




    HTH,
    Duncan


    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    Check out the new downloads - ImageMap.ocx is the VB control that emulates an HTML image map, EventVB.OCX for adding new events to your VB form and adding System Tray support simply, MCL Hotkey for implemenmting system-wide hotkeys in your application...all with source code included.
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

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