News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

A few new functions in files.lib

Started by donkey, December 26, 2004, 08:17:18 PM

Previous topic - Next topic

donkey

I added a few new functions to files.lib that I needed for a project. They are...

IsShortcut
Tests to see if the filename provided is a shortcut.
Parameters:
lpFilename = Pointer to a filename to be examined
Returns TRUE if the filename is a shortcut

ResolveLinkIndirect
Resolves a shortcut returning details about that shortcut. The information is passed
in a structure
Parameters:
pLinkInfo = Pointer to a LINK_INFO structure

LINK_INFO structure members:
pFilename Fully qualified path of the LNK file to be examined, cannot be NULL
pLinkTarget Pointer to a buffer of MAX_PATH to recieve the target, can be NULL
pIconLocation Pointer to a buffer of MAX_PATH to recieve the icon location, can be NULL
dwIconIndex Recieves the icon index (ignored if pIconLocation is NULL)
pDescBuffer Pointer to a buffer to recieve the description, can be NULL
cchDesc Size in bytes of the pDescBuffer buffer
pArgBuffer Pointer to a buffer to recieve the command line arguments, can be NULL
cchArg Size in bytes of the pArgBuffer buffer
pStartIn Pointer to a buffer of MAX_PATH to recieve the startup dir, can be NULL
dwHotkey Recieves the assigned hot-key scan code
dwShowCmd Recieves the show command

Set a buffer pointer to NULL if you do not need that information.
Returns S_OK or an OLE defined error code.

CreateLinkIndirect
Creates a shortcut, based on the information passed in a structure
Parameters:
pLinkInfo = Pointer to a LINK_INFO structure

LINK_INFO structure members:
pFilename Fully qualified path of the LNK file to be created, cannot be NULL
pLinkTarget Pointer to a path specifying the target, cannot be NULL
pIconLocation Pointer to a path where the icon is located, can be NULL
dwIconIndex Specifies the icon index (ignored if pIconLocation is NULL)
pDescBuffer Pointer a description, can be NULL
cchDesc ignored
pArgBuffer Pointer to a string of command line arguments, can be NULL
cchArg ignored
pStartIn Pointer to a path specifying the startup dir, can be NULL
dwHotkey Hot-key scan code (ie VK_S)
dwShowCmd Show command (ie SW_SHOWNORMAL)

Set a buffer pointer to NULL to skip that information
Returns S_OK or an OLE defined error code.

StripFilename
Returns the path portion of a file name in the buffer provided. The buffer must
be of the size MAX_PATH
Parameters:
pszBuffer = Pointer to a buffer in which to copy the path information
pszFilename = Pointer to a file path (this string is preserved)

Returns the offset of the file name portion of the path
ECX is preserved for loop functions


The lib with GoAsm source is available at my website. These functions have not been tested using MASM but should work fine with that assembler. Example of CreateShortcutIndirect...

FILESLIB = C:\GoAsm\Files.lib
CreateLinkIndirect = FILESLIB:CreateLinkIndirect

DATA SECTION
lnkfile DB "C:\TestLink.LNK",0
lnktarget DB "C:\RadASM\RadASM.EXE",0
lnkDesc DB "Description",0
lnkStrt DB "C:\RadASM",0
lnkIcoLoc DB "C:\WinNT\system32\SHELL32.dll",0
lnkArgs DB "/s",0

li LINK_INFO <>

CODE SECTION
invoke CoInitialize,0
mov [li.pFilename],offset lnkfile
mov [li.pLinkTarget],offset lnktarget
mov [li.pIconLocation],offset lnkIcoLoc
mov D[li.dwIconIndex],10
mov [li.pDescBuffer],offset lnkDesc
mov [li.pArgBuffer],offset lnkArgs
mov [li.pStartIn],offset lnkStrt
mov D[li.dwHotkey],VK_S
mov D[li.dwShowCmd],SW_SHOWMINIMIZED
invoke CreateLinkIndirect,offset li

"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable