SPONSORS:






User Tag List

Results 1 to 4 of 4
  1. #1
    Guest

    Interfacing GetFileTime() from Kernel32.dll

    To: QAP Users out there,

    I'm trying to use a DLL function: GetFileTime() from Kernel32.dll and I have a problem:
    Declaration:

    type LPFILETIME is string
    dll ''kernel32.dll''
    BOOL GetFileTimeA (LONG hFile, out LPFILETIME lpCreationTime,
    out LPFILETIME lpLastAccessTime, out LPFILETIME lpLastWriteTime)
    I get the following error:
    Type HANDLE may not be used in a DLL function

    Anybody know how to do this?

    Thanks much!

  2. #2
    Member
    Join Date
    Aug 2003
    Location
    Westlake Village, CA
    Posts
    40
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Interfacing GetFileTime() from Kernel32.dll

    Try the code below. The datatype HANDLE is declared as a long and named HWND in the mswtype.inc file (this comes with SilkTest and can be found in the main program directory).

    [ ] use "mswtype.inc"
    [ ]
    [ ] type LPFILETIME is string
    [ ]
    [-] dll 'kernel32.dll'
    [ ] BOOL GetFileTimeA (HWND hFile, out LPFILETIME lpCreationTime, out LPFILETIME lpLastAccessTime, out LPFILETIME lpLastWriteTime)
    [ ]

  3. #3
    Member
    Join Date
    Apr 2003
    Location
    beed,maharashtra,india
    Posts
    34
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Interfacing GetFileTime() from Kernel32.dll

    Hi...
    Can i get file directory . if i have handle of directory.
    if yes then please advice me..
    Thanking you
    Atul
    Learn and Learn

  4. #4
    Super Member
    Join Date
    Jul 2003
    Location
    Boulder, CO
    Posts
    1,276
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Interfacing GetFileTime() from Kernel32.dll

    If you grow tired of messing with the DLL:

    Here is a catch all vbscript you can customize:

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">set args = WScript.arguments

    fname = args(0)

    for i = 1 to args.Count - 1
    fname = fname &amp; &quot; &quot; &amp; args(i)
    next

    WScript.Echo &quot;Created:&quot;
    WScript.Echo FileCreated(fname)

    WScript.Echo &quot;Last Accessed:&quot;
    WScript.Echo FileLastAccessed(fname)

    WScript.Echo &quot;Last Modified:&quot;
    WScript.Echo FileLastModified(fname)


    'Return the date/time a file was created
    Function FileCreated(Fname)

    FileCreated = &quot;&quot;

    Set fs = CreateObject(&quot;Scripting.FileSystemObject&quot

    if fs.FileExists(Fname) = True then
    Set f = fs.GetFile(Fname)
    FileCreated = f.DateCreated
    end if
    Set f = Nothing
    Set fs = Nothing
    end function


    'Return the date a file was last accessed
    Function FileLastAccessed(Fname)

    FileLastAccessed = &quot;&quot;

    Set fs = CreateObject(&quot;Scripting.FileSystemObject&quot

    if fs.FileExists(Fname) = True then
    Set f = fs.GetFile(Fname)
    FileLastAccessed = f.DateLastAccessed
    end if
    Set f = Nothing
    Set fs = Nothing
    end function



    'Return the date/time a file was last modified
    Function FileLastModified(Fname)

    FileLastModified = &quot;&quot;

    Set fs = CreateObject(&quot;Scripting.FileSystemObject&quot

    if fs.FileExists(Fname) = True then
    Set f = fs.GetFile(Fname)
    FileLastModified = f.DateLastModified
    end if
    Set f = Nothing
    Set fs = Nothing
    end function </pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">If you saved this as getFileStuff.vbs, you could use it like this:

    STRING filename = "somefile.txt"
    LIST OF STRING outStuff
    SYS_Execute("CScript getFileStuff.vbs {filename}", outStuff)
    Print ("{filename} was created on {outStuff[5]}")
    Print ("{filename} was last accessed on {outStuff[7]}")
    Print ("{filename} was last modified on {outStuff[9]}")

    I think TransformDate() can be used to automatically parse the individual date/time items.
    Chris R Mead

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 10:40 PM.

Copyright BetaSoft Inc.