Welcome Guest.   Make a donation to an author on the site October 25, 2014, 01:19:11 PM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Read the full one-year retrospective report on DonationCoder.com.
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: Prev 1 [2]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: Tiny 'Touch' 32 bits program in C (3 kb)  (Read 10554 times)
Gerome
Charter Honorary Member
***
Posts: 154


View Profile WWW Give some DonationCredits to this forum member
« Reply #25 on: October 01, 2006, 02:23:37 PM »

Just for fun, here's a 1kb C (well, C++) version, that has proper system return code smiley


Nice!
Here's a good link btw : http://smallcode.weblogs....gory/optimization-tricks/
Logged

Yours,
(¯`·._.FBSL Help file]
(¯`·._.
Gerome
Charter Honorary Member
***
Posts: 154


View Profile WWW Give some DonationCredits to this forum member
« Reply #26 on: October 01, 2006, 03:17:59 PM »

Hello,

Here is the ported version to FBSL v3 :
One cas easily compare the C version vs the FBSL one and have a look at slight difference of both languages smiley
Compiled as 'tiny' Fbsl executable, it's final weight is around 8Kb.
Formatted for UNKNOWN with the GeSHI Syntax Highlighter [copy or print]
  1. // ********************************
  2. // Author : Gerome GUILLEMIN
  3. // Coded in FBSL v3
  4. // Date : 01st of October 2006
  5. // ********************************
  6. #DllDeclare Kernel32( "CreateFile", "CloseHandle", "GetSystemTime", "SystemTimeToFileTime", "SetFileTime" )
  7.  
  8. Function Main()
  9.    Dim %lngHandle = NULL
  10.    Dim $szFileName * MAX_PATH+1
  11.    If CommandCount() = 2 Then
  12.        StrCpy( szFileName, Command(1) )
  13.        lngHandle = CreateFile(szFileName, GENERIC_WRITE, _
  14.                    FILE_SHARE_READ + FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0)
  15.        If lngHandle AndAlso lngHandle <> INVALID_HANDLE_VALUE Then
  16.            SetFileToCurrentTime( lngHandle )
  17.            CloseHandle( lngHandle )
  18.            Return 1 // => 1 will be the OK return
  19.        End If
  20.    End If
  21. Return 0 // => 0 will be the KO return
  22. End Function
  23.  
  24. Function SetFileToCurrentTime(Byval %hFile)
  25.  Dim $ft * 16 'FILETIME
  26.  Dim $st * 16 'SYSTEMTIME
  27.  
  28.  GetSystemTime(@st)                 // gets current time
  29.  SystemTimeToFileTime(@st, @ft)     // converts to file time format
  30.  Return SetFileTime(hFile, 0, 0, @ft) // sets last-write time for file
  31. End Function

See the attached Zip file to get the whole thing.
Enjoy FBSL !

* Touch.zip (1.07 KB - downloaded 118 times.)
« Last Edit: October 01, 2006, 03:35:55 PM by Gerome » Logged

Yours,
(¯`·._.FBSL Help file]
(¯`·._.
Pages: Prev 1 [2]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.024s | Server load: 0.16 ]