Announcement

Collapse
No announcement yet.

looking voor lost page

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • looking voor lost page

    creating desktop shortcuts, how?

    doing a search on 'shortcuts' i got a number of pages that point to this url:
    unf. my browser reports a 'not found' error when clicking on it. something wrong, lance, tom?



    ------------------
    mailto:[email protected][email protected]</a>
    www.basicguru.com/zijlema/

    Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
    http://zijlema.basicguru.eu
    *** Opinions expressed here are not necessarily untrue ***

  • #2
    it may have been moved to the archives. found it in poffs - here
    it is, so you can get going:

    'message
    'forum: source code
    'topic: pb/dll32: createshortcut() function
    'name: lance edmonds, administrator
    'date: april 29, 1999 06:03 am


    try this (adapted to pb/dll & enhanced by lance edmonds, original was in vb)
    Code:
    $compile exe
    $dim all
    $include "win32api.inc"
    type ****emid
        cb as long
        abid as byte
    end type
    type itemidlist
        mkid as ****emid
    end type
    declare sub shaddtorecentdocs lib "shell32.dll" alias "shaddtorecentdocs" _
        (byval dwflags as long, pv as asciiz)
    declare function shgetpathfromidlist lib "shell32.dll" alias "shgetpathfromidlista" _
        (byval pidl as long, lpszpath as asciiz) as long
    declare function shgetspecialfolderlocation lib "shell32.dll" alias "shgetspecialfolderlocation" _
        (byval hwndowner as long, byval nfolder as long, pidl as any) as long
    %csidl_bitbucket        = &ha
    %csidl_controls         = &h3
    %csidl_desktop          = &h0
    %csidl_desktopdirectory = &h10    ' on desktop
    %csidl_drives           = &h11
    %csidl_favorites        = &h6     ' in favorites
    %csidl_fonts            = &h14
    %csidl_nethood          = &h13
    %cdisl_network          = &h12
    %csidl_personal         = &h5     ' in personal folder
    %csidl_printers         = &h4
    %csidl_programs         = &h2     ' in start menu programs folder
    %csidl_recent           = &h8     ' recent documents list
    %csidl_sendto           = &h9     ' send to menu (handy)
    %csidl_startmenu        = &hb     ' start menu (on top)
    %csidl_startup          = &h7     ' startup group
    %csidl_templates        = &h15
    %shard_path = &h2&
    function createshortcut(hwnd as long, szpath as asciiz, szname as asciiz, lwhere as long) as long
        dim lresult as long
        dim szpathwhere as asciiz * %max_path
        dim lpidlwhere as itemidlist ptr
        dim szpathrecent as asciiz * %max_path
        dim lpidlrecent as long
        dim sztarget as asciiz * %max_path
        dim t&
        on error resume next
        replace "." with "_" in szname
        replace " " with " in szname
        lresult = shgetspecialfolderlocation(hwnd, lwhere, lpidlwhere)
        if istrue lresult then exit function
        reset szpathwhere
        lresult = shgetpathfromidlist(lpidlwhere, szpathwhere)
        if isfalse lresult then exit function
        lresult = shgetspecialfolderlocation(hwnd, %csidl_recent, lpidlrecent)
        if istrue lresult then exit function
        reset szpathrecent
        lresult = shgetpathfromidlist(lpidlrecent, szpathrecent)
        if isfalse lresult then exit function
        shaddtorecentdocs %shard_path, szpath
        ' if not a recent file link, move it to the final position
        if lwhere <> %csidl_recent then
            'wait until file is there to copy
            t& = timer
            do
                sleep 0
            loop until len(dir$(szpathrecent & "\" & szname & ".exe.lnk")) or t& + 3 < timer
            if t& + 3 < timer then exit function
            filecopy szpathrecent & "\" & szname & ".exe.lnk", szpathwhere & "\" & szname & ".lnk"
            kill szpathrecent & "\" & szname & ".exe.lnk"
        end if
        function = -1
    end function
    function pbmain() as long
       ' usage:
       ' param 1 is the current hwnd in case the api opens a dialog - 0 (null) is acceptable
       ' param 2 is the fully qualified path and file name of the exe
       ' param 3 is the shortcut name, must be the exe name *without* the .exe extension
       ' param 4 is the destination identifier (see equate list above)
       if istrue createshortcut(0, "f:\pbdll50\bin\pb5.exe", "pb5", %csidl_desktopdirectory) then
          msgbox "shortcut created successfully!"
       else
          msgbox "failure to create shortcut!"
       end if
    end function
    '############################ follow-up ############################

    dorian darby
    member
    posted april 29, 1999 08:41 am


    i was wondering what the "*"'s in
    type ****emid
    cb as long
    abid as byte
    end type
    type itemidlist
    mkid as ****emid
    end type
    mean, or do you use them to signify (to the programmer) that the first type is not used directly by the code, but is referenced by another type?

    '############################ follow-up ############################

    eric pearson
    member
    posted april 29, 1999 10:52 am


    dorian --
    the bbs software (the ultimate bbs) automatically censors "naughty" words... i'm guessing that the missing characters are something like sh item id without the spaces.
    -- eric

    '############################ follow-up ############################

    francis beaulieu
    member
    posted april 29, 1999 05:21 pm


    thank lance! very usefull!

    '############################ follow-up ############################

    chuck de young
    member
    posted may 10, 1999 10:25 am


    lance, microsoft wants us to release the pidl, per this code :
    void workwithspecialfolder() {
    // allocate a pointer to an item id list
    lpitemidlist pidl;
    // get a pointer to an item id list that
    // represents the path of a special folder
    hresult hr = shgetspecialfolderlocation(null, csidl_personal, &pidl);
    // convert the item id list's binary
    // representation into a file system path
    char szpath[_max_path];
    bool f = shgetpathfromidlist(pidl, szpath);
    // allocate a pointer to an imalloc interface
    lpmalloc pmalloc;
    // get the address of our task allocator's imalloc interface
    hr = shgetmalloc(&pmalloc);
    // free the item id list allocated by shgetspecialfolderlocation
    pmalloc->free(pidl);
    // free our task allocator
    pmalloc->release();
    // work with the special folder's path (contained in szpath)
    ·
    ·
    ·
    }
    i do not have a clue how to call a couple of methods inside the imalloc object from a pointer to the interface. i know it is not much of a leak but i can't have it. any ideas?

    '############################ follow-up ############################

    chuck de young
    member
    posted may 13, 1999 03:22 am


    well, i do not know if anyone will find this here, but i solved the pidl freeing problem using philippe monteil's com wizard for pb open beta product. join this beta folks! the memory leak here is real. i ran a test of seeking special folders a gazillion times with, and without freeing the pidl, and could bring a nt machine to its knees. a small leak, but then, we know about the consequences of these!

    '############################ follow-up ############################

    lance edmonds
    administrator
    posted may 13, 1999 09:45 pm


    a "gazillion" special folders on one machine? must br one of those terabyte sized drives, and possibly "quite a few" user profiles active...
    seriously, i'm not sure how to access the pmalloc->free(pidl) ole function.
    i was under the impression that it was automatically released upon app termination. is this not correct?
    can you post you solution using the com wizard? thanks!
    lance
    powerbasic support

    '############################ follow-up ############################

    chuck de young
    member
    posted may 14, 1999 01:32 am


    i posted it in a separate thread in this forum, as i only dealt with special folder retrieval, not link making.


    ------------------

    Comment


    • #3
      Thanks, Borje!

      Although I don't have the slightest idea what POFFS are/is.


      ------------------
      mailto:[email protected][email protected]</A>
      www.basicguru.com/zijlema/

      Egbert Zijlema, journalist and programmer (zijlema at basicguru dot eu)
      http://zijlema.basicguru.eu
      *** Opinions expressed here are not necessarily untrue ***

      Comment


      • #4
        POFFS, stands for "Power basic OFF-line forum Search". It's a small
        offline search program I once wrote to be able to search among all
        these messages, even when not connected to the Internet.

        It currently contains all postings made to these Forums up to
        October 7th this year. Once things slow down a bit for me (Christmas
        season = 24 hour work days for me right now), I'll update it.

        A big (+10 MB of useful information) download, but it can be worth
        looking at, especially if you, like me, sometimes have a very slow
        and expensive connection that sometimes (in my case - often) makes
        it hard for you from visit here and do online searches.

        You can find it at: http://www.tolken99.com/pb/pbfile_e.htm


        ------------------

        Comment

        Working...
        X