A better way to get AppData location?

To conform better with Vista I have taken to retrieving the "AppData" location in the registry in order to determine a safe place for my app to write files. The code I use is like this:
err = RegReadString (REGKEY_HKCU, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "AppData", appdatapath, PATHLEN, &keysize);
By and large, this works but I have had a few reports that it does not - where the AppData registry entry is corrupt or invalid.  How that arises I have no idea.
But, I'm intrigued by a key in that location on my Vista machine. The key is "!Do not use this registry key" and the value is "Use the SHGetFolderPath or SHGetKnownFolderPath function instead".  Looks like a pretty good clue! 
Can anyone tell me whether these SDK functions will solve my problem, or how they might differ from simply reading the registry string?  Does anyone here use them?
Thanks,
Ian
Solved!
Go to Solution.

Hello Ian,
I'm not really sure why that registry location works some times but not others, but Microsoft definitely wants us to use the function and not the registry.
Note that SHGetKnownFolderPath is too new to be included in the version of the Windows SDK that comes with CVI, but you can definitely use  SHGetFolderPath which works just as well, in Vista and in XP/2000:
#include <shlobj.h>
char path[MAX_PATHNAME_LEN];
SHGetFolderPath (0, CSIDL_COMMON_APPDATA, NULL, SHGFP_TYPE_CURRENT, path);
(you'll have to add shell32.lib to your CVI project).
CSIDL_COMMON_APPDATA gives you the common, "all users" folder. If you want the per-user folder, you can use CSIDL_APPDATA instead.
Luis

Similar Messages

  • I've lost my iPhone 4... How can I find it when the device is offline when using "find my iPhone app"????? Any way of getting a location from it????

    I've lost my iPhone 4... How can I find it when the device is off linesmen using "find my iPhone app"????? Any way of getting a location from it?????

    No. It must be online in order to locate it.
    What To Do If Your iDevice Is Lost Or Stolen
    iPhone, iPod Touch, and iPad
    If you activated Find My Phone before it was lost or stolen, you can track it only if it is connected to the Internet by Wi-Fi or cellular. What you cannot do is track your device using a serial number or other identifying number. You cannot expect Apple or anyone else to find your device for you. You cannot recover your loss unless you insure your device for such loss. It is not covered by your warranty.
    If your iPhone, iPod, iPod Touch, or iPad is lost or stolen what do you do? There are things you should have done in advance - before you lost it or it was stolen - and some things to do after the fact. Here are some suggestions:
    This link, Re: Help! I misplaced / lost my iPhone 5 today morning in delta Chelsea hotel downtown an I am not able to track it. Please help!, has some good advice regarding your options when your iDevice is lost or stolen.
      1. Reporting a lost or stolen Apple product
      2. Find my lost iPod Touch
      3. AT&T. Sprint, and Verizon can block stolen phones/tablets
      4. What-To-Do-When-Iphone-Is-Stolen
      5. iCloud- Use Lost Mode
      6. What to do if your iOS device is lost or stolen
      7. 6 Ways to Track and Recover Your Lost/Stolen iPhone
      8. Find My iPhone
      9. Report Stolen iPad | Stolen Lost Found Online
    It pays to be proactive by following the advice on using Find My Phone before you lose your device:
      1. Find My iPhone
      2. Setup your iDevice on iCloud
      3. OS X Lion/Mountain Lion- About Find My Mac
      4. How To Set Up Free Find Your iPhone (Even on Unsupported Devices)

  • A better way to get current and previous status?

    I'm working on a system where status messages are read into a table for items of equipment. My requirement is to find all the messages arriving within a particular time window, together with the status value and the status value for the previous message sent for that equipment item, if any. This previous message can (and probably will) have a date outside the window I'm looking at, or might not exist at all for a brand new equipment item.
    The table looks something like this:
    create table eq_state
    (eq_id      NUMBER,   -- ID of the equipment
    event_date DATE,     -- Date/Time of the message
    status     NUMBER)   -- Status passed in the messageThere are indexes on (event_date,eq_id) and on eq_id. It'll get very big, so it's important that indexes are used wherever possible.
    Here's what I have so far:
    WITH eq_state AS
    SELECT 1 eq_id, TO_DATE('01/05/2013 12:01:00','DD/MM/YYYY HH:MI:SS') event_date, 1 status FROM DUAL
    UNION ALL
    SELECT 2 eq_id, TO_DATE('01/05/2013 01:01:00','DD/MM/YYYY HH:MI:SS') event_date, 2 status FROM DUAL
    UNION ALL
    SELECT 2 eq_id, TO_DATE('01/05/2013 12:02:00','DD/MM/YYYY HH:MI:SS') event_date, 3 status FROM DUAL
    UNION ALL
    SELECT 3 eq_id, TO_DATE('01/05/2013 10:00:00','DD/MM/YYYY HH:MI:SS') event_date, 4 status FROM DUAL
    UNION ALL
    SELECT 3 eq_id, TO_DATE('01/05/2013 12:03:00','DD/MM/YYYY HH:MI:SS') event_date, 5 status FROM DUAL
    UNION ALL
    SELECT 3 eq_id, TO_DATE('01/05/2013 12:04:00','DD/MM/YYYY HH:MI:SS') event_date, 6 status FROM DUAL
    SELECT eq_id,TO_CHAR(event_date,'DD/MM/YYYY HH:MI:SS') event_date,curr_state,prev_state
    FROM  (SELECT Es.Eq_Id,
                  Es.Event_Date,
                  Es.Status AS Curr_State,
                  Es2.Status AS Prev_State,
                  RANK() OVER (PARTITION BY es.eq_id,es.event_date ORDER BY es2.event_date DESC) the_rank
           FROM   Eq_State Es
           LEFT OUTER JOIN Eq_State Es2
           ON     Es2.Eq_Id = Es.Eq_Id
           AND    Es2.Event_Date < Es.Event_Date
           WHERE  Es.Event_Date BETWEEN TO_DATE('01/05/2013 12:00:00','DD/MM/YYYY HH:MI:SS')
                                    AND TO_DATE('01/05/2013 12:05:00','DD/MM/YYYY HH:MI:SS')) x
    WHERE  the_rank = 1
    ORDER BY 1,2This gives me the desired results and seems to use sensible indexes (I'll spare you the explain plan):
         EQ_ID      EVENT_DATE          CURR_STATE PREV_STATE
             1 01/05/2013 12:01:00          1          
             2 01/05/2013 12:02:00          3          2
             3 01/05/2013 12:03:00          5          4
             3 01/05/2013 12:04:00          6          5So what's the problem? Just curiosity really - the technique of finding the RANK() in the inline view, and then selecting rows where it's equal to 1 seems like a bit of a kludge. Is there a more elegant way to do it? Maybe something using LAG() or KEEP DENSE_RANK LAST?
    I'm still not really up-to-speed with analytic functions, so I'm hoping to learn something from those of you that are!
    ORACLE 11.2.0.1.0 by the way

    I would use another way, firstly sorting by any unique criteria and using joins
    WITH eq_state AS
    SELECT 1 eq_id, TO_DATE('01/05/2013 12:01:00','DD/MM/YYYY HH:MI:SS') event_date, 1 status FROM DUAL
    UNION ALL
    SELECT 2 eq_id, TO_DATE('01/05/2013 01:01:00','DD/MM/YYYY HH:MI:SS') event_date, 2 status FROM DUAL
    UNION ALL
    SELECT 2 eq_id, TO_DATE('01/05/2013 12:02:00','DD/MM/YYYY HH:MI:SS') event_date, 3 status FROM DUAL
    UNION ALL
    SELECT 3 eq_id, TO_DATE('01/05/2013 10:00:00','DD/MM/YYYY HH:MI:SS') event_date, 4 status FROM DUAL
    UNION ALL
    SELECT 3 eq_id, TO_DATE('01/05/2013 12:03:00','DD/MM/YYYY HH:MI:SS') event_date, 5 status FROM DUAL
    UNION ALL
    SELECT 3 eq_id, TO_DATE('01/05/2013 12:04:00','DD/MM/YYYY HH:MI:SS') event_date, 6 status FROM DUAL
    ), sorted as (
      select row_number() over (order by a.event_date) as rn, a.* from eq_state a
    select * from sorted s1
    left join sorted s2 on (s2.rn = s1.rn -1)
    order by s1.rn
            RN      EQ_ID EVENT_DATE                STATUS         RN      EQ_ID EVENT_DATE                STATUS
             1          2 01.05.2013 01:01:00            2                                                       
             2          3 01.05.2013 10:00:00            4          1          2 01.05.2013 01:01:00            2
             3          1 01.05.2013 12:01:00            1          2          3 01.05.2013 10:00:00            4
             4          2 01.05.2013 12:02:00            3          3          1 01.05.2013 12:01:00            1
             5          3 01.05.2013 12:03:00            5          4          2 01.05.2013 12:02:00            3
             6          3 01.05.2013 12:04:00            6          5          3 01.05.2013 12:03:00            5

  • Is there a better way to get rid of desktop icons?

    My project has two things left: 1. get rid of desktop icons during the script 2. Ensure that windows don't open during the script.
    so for part one, I have the following:
    do shell script "defaults write com.apple.finder CreateDesktop -bool " & false
    the problem is I can't change the desktop background picture when I use the above script. Without it, I can but I have icons.
    The second issue is how I set up a handler in the event that windows open during the script, blocking the desktop-image message. I want to close all windows and keep them closed during the script. Here is what I have so far, but it doesn't work:
    on exists windows of processes where the visible is true
    tell application "Finder"
    set willey to get (windows where the (exists) is true) of processes where the visible is true
    set the exists of willey to false
    end tell
    end exists
    PowerBook G4 1.67 Ghz   Mac OS X (10.4.6)  

    Even if you manage to change the static desktop picture, you're going to have to find a way to disable the dynamic desktop picture that many users will have activated. This "Change picture" feature is controlled by Dock.app, not Finder. If you quit or kill the Dock, the system automatically respawns it ad infinitum. The only way around that is to temporarily move or rename dock.app, which requires administrator privileges. I'm not particularly inclined to offer my password to prank apps, are you?
    If I were you I'd take a look at Salling Clicker. I know that sounds crazy, but hear me out: In the Salling distro there is a neat freeware FBA called "SEC Helper" that lets you post Growl-like notices to the user, without the hassle of relying on a Growl install. It has a full-screen option that you can set up just like a slideshow.
    click here to open this script in your editor<pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px">tell application "SEC Helper"
    "/Library/Desktop Pictures/Plants/Petals.jpg"
    show screen picture data (read (POSIX file result as alias) as picture) with full screen
    end tell</pre>

  • My phone has just been stolen with my car,it is reading offline on fmphone,is there any way to get a location while offline?

    Hi i'm in a bad place right now,my car watch and iphone 5s have just been stolen,my phone is reading 'offline'on find my phone, i was wondering if there was any way to locate the phone while offline?,any help would be very much appreciated.thanks in advance Alex.

    Find My iPhone will display the last location of the device for 24 hours:
    Click on the device on iCloud under Devices (even though the dot is gray). It will take you to the map to show you where it was last "seen" online.
    Sorry about your troubles....
    GB

  • Is there a way to get a 'Location services' toggle in the new IOS 7.0 'swipe up'  options?

    I used to have location services toggle in SB settings as i use my iPhone for Sat Nav so regularly switch the location services off and on
    But the new IOS 7.0 doesnt have a location services' toggle
    is there a way to put this toggle on the swipe up menu?
    Or is there a shortcut to turn the location services on and off, instead of going to Settings, Privacy then location services, then off/on

    The Control Center is not user adjustable. Location services, if you're not actively navigating, are not an incredibly huge battery drain, for what it's worth.

  • Any way of getting your current location in Numbers for iOS

    I was looking for a way to get geographic location information from the iPad Core Location API from within Numbers and based on the iPad's location, a cell's value would change based on the location.
    Does anyone know if Numbers supports location information or any way for numbers to ascertain the location of the iPad?
    Thank you.
    Steve

    Nice folks there. I met a few of them last night at the NYC InDesign user group meeting.
    If they can help, that's great.
    Bob

  • Best way to get internet between two buildings???

    Hello all! I have some questions about a possible setup I am thinking of running.
    I have building that has internet coming into it. 15yds away, I have another building (which is brick) that has no internet options. I was thinking about buying two Airport Extreme's, making one the base and using the other one in the other building the access point for WDS. Then buy a couple of the Airport Expresses to push the signal throughout that building.
    Thoughts on this? Is there a better way to get internet between two buildings (without running cables) and then push it through out that building?
    I am open to any an all suggestions.
    Thanks,
    Grant

    Welcome to the discussions!
    Ethernet is always the best choice for signal strength and reliability. If you do not want to run ethernet cable to the second building, your options are down to ethernet powerline adapters and wireless.
    The ethernet powerline adapters work by transmitting the ethernet signal over the AC power line. The difficulty here may be that the other building is on a different electrical circuit, so it may or may not work depending on how the electrical wiring is configured. An electrician could run tests to see if this would work.
    The least reliable option is wireless. To have the best chance of working well, the "sending" and "receiving" routers need to be able to "see" each other through a window or other opening. Be sure to test with a laptop in the second location to see if you will have a strong enough signal to work with before you go this route.

  • A better way to write last_day query

    Hi folks,
    I am looking for a better way to write a query to find last_day in month but if its sunday or holiday it should move to day before last day.
    So for example if 31 is sunday it should go for 30, if 30 is holiday it should move down to 29.
    I got this so far but the connect by level is hardcoded to 15. Want to see if there is a better way to get this working:
    select max(datum)
      from (    select last_day(trunc(sysdate)) - level + 1 as datum
                  from dual
            connect by level < 15)
    where to_char(datum, 'day') != 'sunday'    
       and to_char(datum, 'DDMM') not in
             ('3012')Best regards,
    Igor

    Like this
    select to_char(last_day_month, 'Day') day_is,
           last_day_month,
           last_day_month - case when to_char(last_day_month, 'fmday') = 'sunday' then 1
                                 when to_char(last_day_month, 'ddmm' ) = '3012'   then 1
                                 else 0
                            end last_business_day_month
      from (
              select last_day(add_months(trunc(sysdate, 'year'), level-1)) last_day_month
                from dual
              connect by level <= 12
    DAY_IS    LAST_DAY_MONTH LAST_BUSINESS_DAY_MONTH
    Tuesday   31-JAN-12      31-JAN-12              
    Wednesday 29-FEB-12      29-FEB-12              
    Saturday  31-MAR-12      31-MAR-12              
    Monday    30-APR-12      30-APR-12              
    Thursday  31-MAY-12      31-MAY-12              
    Saturday  30-JUN-12      30-JUN-12              
    Tuesday   31-JUL-12      31-JUL-12              
    Friday    31-AUG-12      31-AUG-12              
    Sunday    30-SEP-12      29-SEP-12              
    Wednesday 31-OCT-12      31-OCT-12              
    Friday    30-NOV-12      30-NOV-12              
    Monday    31-DEC-12      31-DEC-12 

  • Is there a way of getting whatsapp on my ipad

    i have a ipad 3 HD it's updated to iOS 6.1.3 i just want to know if there are ways of getting whatsapp on the ipad ... normally the hypes about that whatapps can only be used with the iphone etc.

    I was not being sarcastic even though you might have thought I was.
    Talking to developer of a product is alway better way of getting some to chance instead of ranting on the wrong forum.
    Allan

  • Getting xsd location from a variable

    Hi we run std 2012.  In my xml file adapter I don't see an option for mapping the xsd source file to anything but a hardcoded value.  Is there a way to get the location from a variable?

    Hi db042190,
    By design, there is no expression option for XSD location in the advanced editor of XML Source. It only support hard code the location in this page.
    While we can click the Data Flow Task that contains the XML Source component to open the Properties pane, then use expression to control the property like [XML Source].[XMLSchemaDefinition] property in Expressions property.
    The following screenshot is for your reference:
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • Getting the location of non-transperant pixels in an image

    Hello everybody,
    I'm not really new into java, but I am new at working with images... and since I'm making this game i simply have to ^^, anyway here's my problem:
    I'm trying to test for collosion (if a part of a character/player hits an object (enemy, wall, ground) in a level) and to do that i came up with the following idea:
    I'll make this special class called ImagePixels, so when i get/create a new image testImage (in an other class, for example the class player or levelobject) I can also create a new ImagePixel object, like this:
    private Image characterStandRight;
    private void getImages()
              MediaTracker tracker = new MediaTracker(this);
              characterStandRight = getImage(getCodeBase(), "Images/"+player.getCharacterName()+"/standright.gif");
              tracker.addImage(characterStandRight, 1);
              test = new ImagePixels(characterStandRight);
              test.returnPixelLocation();
              try
                   tracker.waitForAll();
              catch (Exception exception)
         }  But i simply don't know an effecient way of getting these locations :( (i tried the ComponentColorModel class and some more)....
    and I'm not even sure if this is the best way to test for collosion... :( any1 can help me??
    Patrick,

    O noes, nobody answers :(

  • HT2513 How do I get the location to print in the monthly view?

    Is there a way to get the location to show as well as print in the monthly view?  The events that I'm concerned about are 'all day' events in a separate calendar.

    Rich media in PDF isn't designed for print workflows so you cannot control what appears - you should just get a bitmap 'screenshot' of whatever the viewport was displaying at the time.

  • Is there any way to get a thread moved to a different sub forum?

    I have a rather long and highly technican thread that was posted under All In One Drivers and Software when it should have been posted in Install and Setup.
    It is still unsolved and I think it would be more relevant in the other sub - and so it might get solved.
    Thanks
    Tom

    Hello Tom, 
    Due to the age and length of the thread you are referring to, I would suggest that creating a new thread on the correct board would be a better way to get a fresh perspective to your question.  
    Let us know if you have other questions.  
    OrnahP
    HP Support Forums Moderator
     Clicking the "Kudos Star" to the left is a great way to say thanks!
     When your problem has been solved, accept the solution by clicking "Accept as Solution" to help other members in the future!
    Rules of Participation

  • Most efficient way to get row count with a where clause

    Have not found a definitive answer on how to do this.  Is there a better way to get a row count from a large table that needs to satisfy a where clause like so:
    SELECT COUNT(*) FROM BigTable WHERE TypeName = 'ABC'
    I have seen several posts suggesting something like 
    SELECT COUNT(*) FROM BigTable(NOLOCK);
    and 
    selectOBJECT_NAME(object_id),row_count from sys.dm_db_partition_stats
    whereOBJECT_NAME(object_id)='BigTable'but I need the row count that satisfies my where clause (i.e.: WHERE TypeName = 'ABC')

    It needs index to improve the performance. 
    - create index on typename column
    - create a indexed view to do the count in advance
    -partition on type name (although it's unlikely) then get count from the system tables...
    all those 3 solutions are about indexing.
    Regards
    John Huang, MVP-SQL, MCM-SQL, http://www.sqlnotes.info

Maybe you are looking for

  • Problem with calculation in report.

    please let me know about below code . What can be possible errors .Because I didn't get true calculations . My purpose is to get ztab-pvprs for every material. CLEAR atab . REFRESH atab .   SELECT smblnr sbudat z~matnr          zwerks zbwart z~menge

  • Enable/disable buttons

    Hi All I have created an application wherein datablock is supposed to display 5 records at a time. In addition to it i have displayed 5 buttons alonside these records. But all the buttons are addresed by single name. I want to change the enable/disab

  • Wireless connection fluctuations!

    I purchased a Toshiba Tecra M3 1.73Ghz with 802.11bg wireless in July this year and it's been working fine until about a month ago. Upon startup, my wireless connection registers 58MBps (and 'excellent' signal strength) but within 5 minutes, that dro

  • [Bug] [pagetemplate-metadata]  Was: [Bug] [JSP Editor]

    Edit: Ok the problem happens after you manually move pages and do a project refresh, the /META-INF/pagetemplate-metadata.xml file's content isn't updated and thus bad references show up everywhere in your project. ~ Simon Original: Hello JDeveloper t

  • Unrecognized I18N key:

    I tried out the Sun Update Connection web interface. Seems neat, but I'm get the following error message for every patch I try to install this way: Unrecognized I18N key: "swup.server.smpatch.". Please contact Sun Support for comment explanation I in