Getting the Windows Directory in OpenScript

>I know that this question has been posted to the list before, but I
>can't recall the answer and I've not been able to get the archive
>search engine located in Australia to work lately...
>
>So...How do you get the Windows directory using OpenScript?
>
>I noticed there is a GetWindowsDirectory function in KERNEL, but how
>do you actually use it? I know how to link to it, but I'm not acquainted
>with Windows programming enough to call it properly from
>OpenScript.
>
>TIA
Here are a couple solutions, first from Tim Barham:

Try this, Fred...

 -- In your book script

    to handle enterApplication
        linkDLL "KERNEL"
            WORD getWindowsDirectory (POINTER, WORD)
            WORD GlobalAlloc(WORD,DWORD)
            WORD GlobalFree(WORD)
            WORD GlobalHandle(WORD)
            POINTER GlobalLock(WORD)
            WORD GlobalUnlock(WORD)
        end
    end

    to get getWinPointer nSize
        local word hMem
        local retValue
        hMem = GlobalAlloc(66,nSize)
        return GlobalLock(hMem)
    end

    to get freeWinPointer pMem
        local word hMem, retValue
        hMem = GlobalHandle(item 1 of pMem)
        retValue = GlobalUnlock(hMem)
        return GlobalFree(hMem)
    end

 -- wherever...

    to get winDir
        buffer = getWinPointer (256)
        get getWindowsDirectory (buffer, 255)
        winDir = pointerString (0, buffer)
        get freeWinPointer (buffer)
        return winDir
    end
Tim.

 ---------------------------------------------------------------------------
Tim Barham
tbarham@vcrpmap.telecom.com.au
 ---------------------------------------------------------------------------
Next from Tim Pearson:

to get winDir
        if "GetWindowsDirectory" is not in DLLFunctions("KERNEL")
                linkDLL "KERNEL"
                        WORD    GetWindowsDirectory(STRING,WORD)
                end
        end
        -- there's 257 spaces between the quote marks as per Tim Pearson
        buffer = "                                                  "&\
        "                                                  "&\
        "                                                  "&\
        "                                                  "&\
        "                                                         "
        get GetWindowsDirectory(buffer,256)
        return buffer&"\"
end

to handle buttonclick
        get windir()
        put it
end
Take your pick.

John

============================================================ John R. Hall 520-626-7343 Biomedical Communications 520-626-2145 (FAX) Arizona Health Sciences Center jhall@biocom.arizona.edu Tucson, AZ 85724 ============================================================

Brian Parkhurst
University of Washington
Box 357260
Seattle, WA 98195-7260
206/543-9175