xdg wrote:

CSIDL_LOCAL_APPDATA is a subroutine. So you've got to call it to return the right numeric flag for GetFolderPath.

$realhome = Win32::GetFolderPath( CSIDL_LOCAL_APPDATA() );

Revising the relevant code per your suggestion ...

if ($^O eq 'MSWin32') { require Win32; import qw(CSIDL_LOCAL_APPDATA); $realhome = Win32::GetFolderPath( CSIDL_LOCAL_APPDATA() ); }

... I now get this error:

Undefined subroutine &main::CSIDL_LOCAL_APPDATA called at import.pl li +ne 11.

jimk

Update:Or, from the command-prompt:

F:\AAAother\data>perl -MExporter -e "require Win32; Exporter::import ' +CSIDL_LOCAL_APPDATA'; print Win32::GetFolderPath( CSIDL_LOCAL_APPDATA +() );" Undefined subroutine &main::CSIDL_LOCAL_APPDATA called at -e line 1.

Further update:I just consulted the MS documentation, which provides 0x001c as the hex numerical value for CSIDL_LOCAL_APPDATA (). Substituting that into the previous code (and simplifying a bit), I get:

if ($^O eq 'MSWin32') { require Win32; print Win32::GetFolderPath( 0x001c ), "\n"; }

... which DWIMs on my system as:

C:\Documents and Settings\kbuser\Local Settings\Application Data

(Big sigh of relief!) Now, let's see if it works in the application from which all of the foregoing is excerpted. Thanks for your help.

jimk

Yet another update:Although the path listed immediately above is the return value generated by GetFolderPath (both in my implementation and in that suggested later by xdg), no such path could be found on my system, at least not through Windows Explorer/My Computer. That's because the directory level 'Local Settings' is absent. In order to get my application to work, I had to do the following (done from memory, so I don't guarantee it):

$realhome = Win32::GetFolderPath( CSIDL_LOCAL_APPDATA() ); $realhome =~ s|(.*?)\\Local Settings(.*)|$1$2|;


In reply to Re^2: Win32 CSIDL_LOCAL_APPDATA by jkeenan1
in thread Win32 CSIDL_LOCAL_APPDATA by jkeenan1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.