Standard code template by WKS Controls25th Oct 2003 13:43
|
---|
Summary Standard code template Description Standard code template and how I call windows DLLs example Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com Rem Project: new_standard Rem Created: 10/15/2003 5:51:08 AM remstart Rem ***** Main Source File ***** Rem+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Rem+ PROGRAM DESCRIPTION SECTION + Rem+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Rem WALTER K SHEETS Rem template for dark bascic Rem SOFTWARE NOTICE Rem OCT.-15-2003 Rem Rem Copyright (c) standard template Rem Rem Purpose:template for DARKBASIC Rem Rem >MAJOR PROCESSING STEPS: Rem Seq Remarks Rem --- -------------------------------------------------------- Rem 1 Setup constants Rem 2 GLOBAL defination Rem 3 Command line interface and command array setup Rem 4 Collect systems information Rem 5 seup wanted system enviromental varibales Rem 6 add includes Rem 7 setup DLL Table and check for exists of DLL that are in the DLL TABLE Rem 8 Main section Rem Rem >COMMAND LINE Rem /D Detail of program fuctional Rem /? Standard program information Rem /W Enable windows mode Rem Rem >ISSUES: Rem Ltrim$,trim$,ltrim$ not working right adds extra char on end Rem Rem >USEAGE: Rem This snippet of code will be use as the stand front of all code I write Rem Rem >WARNING: Rem THIS CODE IS SUBJECT TO CHANGE WITHOUT NOTICE AND DOES NOT REPRESENT Rem A COMMITMENT ON PART OF Walter Sheets IN ANY PART OR FORM. THIS SOFTWARE Rem IS for PUBLIC DOMAIN. Rem Walter K Sheets MAKE NO WARRANRIESRem EITHER EXPRESS Rem OR IMPLIED ON ANY PART OF THIS SOFTWARE PROGRAM. Rem Rem ANY DIRECT INCIDENTAL OR CONSEQUENTIAL DAMGES SUCH AS, BUT NOT LIMITED TO, Rem LOSS OF ANTICIPATED PROFITS OR BENFITS, CAUSE BY MALFUNCTION, DEFECT, OR Rem OTHERWISE, AND WITH RESPECT TO BREACH OF ANY EXPRESS OR IMPLIED WARRANTY, Rem ARE NOT THE RESONSIBILITY OF Walter K Sheets OR ANYONE ELSE WHO HAS Rem BEEN INVOLED IN THE DESIGN, PRODUCTION OR DELIVERY OF THIS SOFTWARE PROGRAM Rem AND, TO THE EXTENED PERMITTED BY LAW, ARE HEARBY EXCLUDED BOTH FOR PROPERTY Rem Rem IN PLAIN AND SIMPLE WORDS USE AT YOUR OWN RISK Rem Rem **************************************************************************** Rem BUGS & REVISION HISTORY Rem DATE RemARKS INTCODE Rem --------------- ---------------------------------------------- -------- Rem 8/15/2003 Creation Date Walter K Sheets Rem 8/15/2003 release date walter K sheets Rem 9/12/2003 update Rem ************************************************************************************* Rem issues DBCOMMDLG_DLL Rem ------------------------- -------------------------------------------------------- Rem compling error all "(quote) must have a matching "(Quote) even in Remarks rem rem Rem Varbale and Lable nameing conventions use im this code: Rem Global Constants: C_xxxxx All start with C_ Rem Macro Constant: M_xxxxx All macro start with M_ Rem Global Varable: G_XXXXX All Gloabl varables start with G_ Rem Local Varable L_xxxxx All local start with L_ Rem Subroutine S_xxxxx Subroutine Rem Function F_xxxxx Function Rem pointer xxxx_ptr All string, varables, memory block pointer end with _pTR Rem rem Type size prefix Number range rem -------------- --------- ------ ------------------------------ Rem STRING Var st ASCII string seq. hex 0 ENd OF STRING Rem BOOLEAN 1 Byte bl 0 to 1 Rem BYTE 1 byte by 0..255 / -127..128 Rem WORD 2 byte wd 0..65,535 / -32,767..32,768 Rem DWORD 4 byte dw 0..4,294,967,296 / -2,147,483,647..2,147,483,648 Rem INTEGER 4 bytes in –2,147,483,648 to 2,147,483,647 Rem REAL 4 Bytes rl 3.4E +/- 38 (7 digits) rem FLOAT 4 Bytes fl 23 bits Static 8 bits Exponencial, a 15 digit number Rem DOUBLE INTEGER 8 byte di 0..8,589,934,592 / -4,294,967,295..4,294,967,296 Rem DOUBLE FLOAT 8 byte df 48 bits Static 14 bits Exponencial, a 32 digit number Rem Rem Rem >COMPILEING REQUIREMENTS: rem (1)DB BASIC PRO 5.1. rem (2)Matrix1utility.DLL place in the complier\plugins-user folder. rem (3)DEBUGLOGdll.dll place in the complier\pligins-user folder. rem (4)create a new folders and add files Rem Dark Basic Professional + rem | Rem +---compiler Rem | +---effects Rem | +---lang Rem | | \---english Rem | +---plugins Rem | \---plugins-user Rem | Matrix1utility.DLL <=place in the complier\plugins-user folder.mat rem | DEBUGLOGdll.dll <=place in the complier\pligins-user folder. rem | Rem +---DLLs Rem | NTPORT.DLL <=use to demo the DLL table and commands Rem | Network.dll <=use to demo the DLL table and commands rem | DBCOMMDLG.dll <=use to demo the DLL table and commands Rem | windows_errors.txt <=use for standard windows error rem rem Detail of files added Rem TPC Plugin Installation Rem >> DebugLog (C) Robert Knight 2003 Rem ======================= Rem STEP 1: (Essential) Rem Copy the .dll file to your Dark Basic Professional\Compiler\plugins-user folder, typically this will be: Rem C:\Program Files\Dark Basic Software\Dark Basic Professional\Compiler\plugins-user Rem Copy the dbp_debug.exe file into your C:\Program Files folder (it MUST be this location, nowhere else) Rem Rem STEP 2: (Not essential, just makes editor highlight new commands) Rem Copy the .ini file to your Dark Basic Professional\Editor\Keywords folder, typically this will be: Rem C:\Program Files\Dark Basic Software\Dark Basic Professional\Editor\Keywords Rem Rem Notes: Rem 1) The debug log is stored in C:\dbp_debug.txt rem rem A directory under Professial Basic call DLLs which holds Rem Need in: Rem C:\Program Files\Dark Basic Software\Dark Basic Professional\Compiler\plugins-user Rem Matrix1utility.DLL is a command libary follow is the detail of it: Rem Copyright © 2002-2003 Ian Mold (Matrix1 software) Rem Permission to copy, use, modify, sell and distribute this software is Rem granted provided this copyright notice appears in all copies. Rem This software is provided “as-is†without express or implied warranty, Rem and with no claim as to its suitability for any purpose. Rem This software contains several 'small' packages of commands for general use. Rem None of this is rocket science - just a few simple things that I thought were Rem missing from DBPro (and for practicing DLLs). Rem Rem Just drop the dll into your compiler\plugins-user folder in the DBPro programs folder, Rem and the ini file into your editor\keywords folder. Rem Rem Strings Rem INSTR - Search for a string within a string. Rem Pos=INSTR(Source$, Search$, StartPos) Rem Pos=INSTR(Source$, Search$) Rem LTRIM$ - Remove leading spaces from the source string Rem New$=LTRIM$(Source$) Rem RTRIM$ - Remove trailing spaces from the source string Rem New$=RTRIM$(Source$) Rem TRIM$ - Remove both leading and trailing spaces from the source string Rem New$=TRIM$(Source$) Rem MID$ - Extract a string from another string Rem New$=MID$(Source$, StartPos, Length) Rem PADLEFT$ - Expand a string by adding leading spaces Rem New$=PADLEFT$(Source$, FinalSize) Rem PADRIGHT$ - Expand a string by adding trailing spaces Rem New$=PADRIGHT$(Source$, FinalSize) Rem Utility Rem MIN/MIN$ - Returns the minimum of two values provided Rem MAX/MAX$ - Returns the maximum of two values provided Rem INK FOREGROUND - Set the ink foreground colour ex:INK FOREGROUND rgb(0,0,0) Rem INK BACKGROUND - Set the ink background colour ex:INK BACKGROUND rgb(0,0,0) Rem GET INK FOREGROUND - Get the ink foreground colour ex: Colour=GET INK FOREGROUND() Rem GET INK BACKGROUND - Get the ink background colour ex: Colour=GET INK BACKGROUND() Rem Memory Rem Note, QWORD means Quad-word (ie 8 bytes) Rem POKE - Set memory addresses Rem POKE BYTE Addr, Value Rem POKE WORD Addr, Value Rem POKE DWORD Addr, Value Rem POKE QWORD Addr, Value Rem POKE FLOAT Addr, Value Rem POKE DOUBLE Addr, Value Rem POKE STRING Addr, Value$ Rem PEEK - Read a value from a memory address Rem Value=PEEK BYTE(Addr) Rem Value=PEEK WORD(Addr) Rem Value=PEEK DWORD(Addr) Rem Value=PEEK QWORD(Addr) Rem Value=PEEK FLOAT(Addr) Rem Value=PEEK DOUBLE(Addr) Rem Value$=PEEK STRING(Addr) Rem Other - Get the address of a string Rem Addr=GET STRING PTR(Source$) Rem Zones Rem SET ZONE - Create a 2D or 3D zone Rem SET ZONE zoneNo, X1, Y1, Z1, X2, Y2, Z2 Rem SET ZONE zoneNo, X1, Y1, X2, Y2 Rem ZONE - Check for a coordinate within a zone Rem ZoneNo=ZONE(X, Y) Rem ZoneNo=ZONE(X, Y, Z) Rem CLEAR ZONE - Clear zones Rem CLEAR ZONE zoneNo Rem CLEAR ALL ZONES Rem System Rem HITIMER - Uses the high frequency timer to get the current tick value Rem If you specify a frequency of 60, the tick will increase once every Rem 60th of a second. ex:CurrentTick=HITIMER(Frequency) Rem GET DISPLAY WIDTH - Get the current actual display width. ex:Width=GET DISPLAY WIDTH() Rem GET DISPLAY HEIGHT - Get the current actual display height. ex:Height=GET DISPLAY HEIGHT() Rem GET PROCESSOR SPEED - Gets the current processor speed. ex: MhzSpeed=GET PROCESSOR SPEED() Rem REGISTER APPLICATION - Registers the name specified, and returns 1 if the name is free for use Rem Result=REGISTER APPLICATION( Name$ ) Rem ************************************************************************************************* Rem Rem C/C++ type physical representation Rem void used as a placeholder to mean ‘nothing’ or ‘no value’ Rem int 32-bit (4-byte) signed word Rem unsigned 32-bit (4-byte) unsigned word. Rem double 64-bit (8-byte) IEEE binary floating number Rem double*(1) 32-bit (4-byte) pointer to a double. Rem LPSTR 32-bit (4-byte) pointer to 0-terminated string of 8-bit ANSI characters. Rem char* 32-bit (4-byte) same as LPSTR Rem LPCSTR 32-bit (4-byte) same as LPSTR but pointed-to string cannot be modified. Rem LPVOID 32-bit (4-byte) pointer, not specified to what. Rem BYTE* 32-bit (4-byte) pointer to a byte (usually used to point to a buffer of data.) Rem LPMSG 32-bit (4-byte) pointer to a Windows MSG structure. Rem HANDLE an unsigned number, used to designate an object. Rem HWND a HANDLE of a window. Rem HCONTAINER a HANDLE to an EZTwain container object. Rem BOOL 32-bit (4-byte) same as int Rem HPALETTE a HANDLE specifically for a Windows GDI palette. Rem HDC a HANDLE of a Windows GDI Device Context. Rem HFILE a HANDLE of a Windows file, for CreateFile, Write, _lclose, … Rem Rem C++ Variab | VB Type | DB TYPE Rem ---------- | ------------------------------------------------ | --------------------------------- Rem ATOM | ByVal variable as Integer 2 bytes | Word Rem BOOL | ByVal variable as Long 4 bytes | Dword Rem BYTE | ByVal variable as Byte 1 byte | Byte Rem CHAR | ByVal variable as Byte 1 byte | Byte Rem COLORREF | ByVal variable as Long 4 bytes | Dword Rem DWORD | ByVal variable as Long 4 bytes | Dword Rem HWND | ByVal variable as Long 4 bytes | Dword Rem HDC | ByVal variable as Long 4 bytes | Dword Rem HMENU | ByVal variable as Long 4 bytes | Dword Rem INT | ByVal variable as Long 4 bytes | Dword Rem UINT | ByVal variable as Long 4 bytes | Dword Rem LONG | ByVal variable as Long 4 bytes | Dword Rem LPARAM | ByVal variable as Long 4 bytes | Dword Rem LPDWORD | variable as Long 4 bytes | Dword Rem LPINT | variable as Long 4 bytes | Dword Rem LPUINT | variable as Long 4 bytes | Dword Rem LPRECT | variable as Type any variable of that User Type | Rem LPSTR | ByVal variable as String | string Rem LPCSTR | ByVal variable as String | string Rem LPVOID | variable As Any use ByVal when passing a string | Rem LPWORD | variable as Integer | Rem LPRESULT | ByVal variable as Long | Rem NULL | ByVal Nothing or ByVal 0& or vbNullString | Rem SHORT | ByVal variable as Integer | Rem VOID | Sub Procecure not applicable | Rem WORD | ByVal variable as Integer | Rem WPARAM | ByVal variable as Long | Rem Rem VB DB vb TO db C++ Rem type char Memory requiRement memory requiRements ----------- ------------- Rem byte 1 byte 0-255 1 byte 0-255 Unsigned char Rem word N/A 2 bytes Unsigned shor Rem integer 2 bytes 4 byte SINGLE Signed long Rem Dword N/A 4 bytes LONG Unsigned long Rem float N/A 4 BYTES LONG Float Rem string 1 byte per char 1 byte per char LPSTR/DWORD. Rem double float N/A 8 Bytes Double Rem double integer N/A 8 Bytes __int64 Rem currency 8 bytes N/A Rem Booelean 2 bytes 1 bytes 0/255 Rem LONG 4 bytes N/A Rem SINGLE 4 bytes N/A Rem 0ate 8 bytes N/A Rem object 4 bytes N/A Rem Variant 16 bytes per char N/A Rem Rem Code Listing 1: Determining Which OLE Library is Installed Rem Play sound Remend Rem call dll( dll_winmm.dll,"sndPlaySoundA",lpszSoundName , uFlags ) Rem Rem SubClassing Rem **************************************************************************** Rem call dll( USER32_DLL,"CallWindowProcA",lpPrevWndFunc , hwnd , msg , wParam , lParam ) Rem * GLOBAL program constant start with C_ * Rem call dll( USER32_DLL,"SetWindowLongA",hwnd , nIndex , dwNewLong ) Rem **************************************************************************** Rem Rem Run associated EXE #constant C_project "New_standard1" Rem call dll( SHELL32_DLL.dll,"ShellExecuteA",hwnd , lpOperation , lpFile , lpParameters , lpDirectory , nShowCmd ) #constant C_copyright "copyright (c) WKSControls" Rem #constant C_version "09/30/2003" Rem List window handles #constant C_programer "Walter K. Sheets" Rem call dll( USER32_DLL",lpEnumFunc , lParam ) #constant C_program "New_standard1" Rem #constant C_crlf chr$(10)+chr$(13) Rem Find prior instance of EXE #constant C_PI 3.142857143 Rem call dll( USER32_DLL,"FindWindowA",lpClassName , lpWindowName ) #constant C_e_natural_log 2.71828 Rem #constant C_on 255 Rem Draw dotted rectangle #constant C_off 0 Rem call dll( USER32_DLL,"DrawFocusRect",hdc , lpRect As RECT) #constant C_True 255 Rem #constant C_False 0 Rem Invert colors of rectangle Rem call dll( USER32_DLL,"InvertRect",hdc , lpRect As RECT) Rem Rem **************************************************************************** Rem Get cursor position Rem * Macros all micro start with M_ * Rem call dll( USER32_DLL,"GetCursorPos",lpPoint As POINTAPI) Rem **************************************************************************** Rem #constant M_DEBUG_WAIT print "debug here====>":wait key Rem Always on top #constant M_LOAD_DLL IF not dll exist(DLL_NUMBER) THEN load dll G_DLL_TABLE$(DLL_NUMBER) ,DLL_NUMBER Rem call dll( USER32_DLL,"SetWindowPos",hwnd , hWndInsertAfter , x , y , cx , cy , wFlags ) #constant M_DELETE_DLL IF dll exist(DLL_NUMBER) THEN DELETE DLL DLL_NUMBER Rem #constant M_DETAIL G_DETAIL=255 Rem Send messages to a window Rem call dll( USER32_DLL,"SendMessageA",hwnd , wMsg , wParam , lParam As Any) #constant M_WAIT_USER print "Any key to continue" : while len(inkey$())=0 and mouseclick()=0 :endwhile Rem #constant M_DETAIL_OUTPUT print Rem Find directories #constant M_debuglog disable debuglog Rem call dll( KERNEL32_DLL,"GetWindowsDirectoryA",lpBuffer , nSize ) Rem call dll( KERNEL32_DLL,"GetSystemDirectoryA",lpBuffer , nSize ) `#constant M_debuglog enable debuglog : clear debuglog : debuglog get date$() : debuglog get time$() Rem call dll( KERNEL32_DLL,"GetTempPathA",nBufferLength , lpBuffer ) `#constant M_WAIT_USER Rem Rem call dll( KERNEL32_DLL,"GetCurrentDirectory",nBufferLength , lpBuffer ) `#constant M_DETAIL_OUTPUT debuglog Rem Hide window Rem Text alignment Rem **************************************************************************** Rem call dll( dll_gdi32,"GetTextAlign",hdc ) Rem * Global note Global commands are upper case, my convention only * Rem call dll( dll_gdi32,"SetTextAlign",hdc , wFlags ) Rem **************************************************************************** Rem Global G_APPDIR$ Rem Flash a title bar Global G_LIBDIR$ Rem call dll( USER32_DLL,"FlashWindow",hwnd , bInvert ) Global G_WORKDIR$ Rem Global G_HELPDIR$ Rem Manipulate bitmaps Global G_INIFILE$ Rem call dll( dll_gdi32,"BitBlt",hDestDC , x , y , nWidth , nHeight , hSrcDC , xSrc , ySrc , dwRop ) Global G_COMNAME$ Rem call dll( dll_gdi32,"PatBlt",hdc , x , y , nWidth , nHeight , dwRop ) Global G_COMDESC$ Rem call dll( dll_gdi32,"StretchBlt",hdc , x , y , nWidth , nHeight , hSrcDC , xSrc , ySrc , nSrcWidth , nSrcHeight , dwRop ) Global G_NEWCOM$ Rem call dll( dll_gdi32,"CreateCompatibleBitmap",hdc , nWidth , nHeight ) Global G_DBPDIR$ Rem call dll( dll_gdi32,"CreateCompatibleDC",hdc ) Global G_PLUGINSUSER$ Rem Global G_PRINTCNT Rem Rotate text Global G_APPDIR$ Rem call dll( dll_gdi32,"CreateFontIndirectA",lpLogFont As LOGFONT) Global G_APPFILE$ Rem Global G_WORKDIRNAME$ Rem Timing Global G_COMMANDDIR$ Rem call dll( KERNEL32_DLL,"GetTickCount",) Global G_NEW_COMDIR$ Rem Global G_DLLDIR$ Rem File information Global G_WINDOW_ENABLE Rem call dll( KERNEL32_DLL,"GetFileAttributesA",lpFileName ) Global G_TMEM Rem call dll( KERNEL32_DLL,"GetFileSize",hFile , lpFileSizeHigh ) Global G_DMEM Rem call dll( KERNEL32_DLL,"GetFullPathNameA",lpFileName , nBufferLength , lpBuffer , lpFilePart ) Global G_SMEM Rem Global G_ERROR_CODE Rem Get window information Global G_DETAIL Rem call dll( USER32_DLL,"GetClassNameA",hwnd , lpClassName , nMaxCount ) Global G_SCREEN_COLOR Rem call dll( USER32_DLL,"GetWindowTextA",hwnd , lpString , cch ) Global G_FONT_FOREGROUND Rem call dll( USER32_DLL,"GetParent",hwnd ) Global G_FONT_BACKGROUND Rem Rem Identify window at cursor Rem *************************************************************************** Rem call dll( USER32_DLL,"WindowFromPoint",xPoint , yPoint ) Rem * PRESET Global note Global commands are upper case, my convention only Rem Rem *************************************************************************** Rem Registry editing Rem call dll( dll_advapi32.dll,"RegCreateKeyA",hKey , lpSubKey , phkResult ) G_APPDIR$ = get dir$() Rem call dll( dll_advapi32.dll,"RegDeleteKeyA",hKey , lpSubKey ) G_WORKDIRNAME$="commands" Rem call dll( dll_advapi32.dll,"RegDeleteValueA",hKey , lpValueName ) Rem call dll( dll_advapi32.dll,"RegQueryValueExA",hKey , lpValueName , lpReserved , lpType , lpData As Any, lpcbData ) G_DBPDIR$="C:\Program Files\Dark Basic Software\Dark Basic Professional\" Rem call dll( dll_advapi32.dll,"RegSetValueExA",hKey , lpValueName , Reserved , dwType , lpData As Any, cbData ) Rem G_LIBDIR$=G_DBPDIR$+"libary\" Rem Drawing functions G_WORKDIR$=G_DBPDIR$+G_WORKDIRNAME$+"\" Rem call dll( dll_gdi32,"MoveToEx",hdc , x , y , lpPoint As POINTAPI) G_HELPDIR$=G_DBPDIR$+"help\" Rem call dll( dll_gdi32,"LineTo",hdc , x , y ) G_DLLDIR$=G_DBPDIR$+"DLLs\" Rem call dll( dll_gdi32,"Ellipse",hdc , X1 , Y1 , X2 , Y2 ) G_NEW_COMDIR$=G_HELPDIR$+"new_com\" Rem G_COMMANDDIR$=G_DBPDIR$+"commands\" Rem Get icon G_COMPILERDIR$=G_DBPDIR$+"compiler\" Rem call dll( SHELL32_DLL.dll,"ExtractIconA",hInst , lpszExeFileName , nIconIndex ) G_PLUGINSUSER$=G_COMPILEDIR$+"plugins-user\" Rem G_TMEM=system tmem available() Rem Screen capture G_DMEM=system dmem available() Rem call dll( USER32_DLL,"SetCapture",hwnd ) G_SMEM=int(abs(system smem available())) Rem call dll( dll_gdi32,"CreateDCA",lpDriverName , lpDeviceName , lpOutput , lpInitData As DEVMODE) INFOFILE$=G_APPDIR$+C_program+".TXT" Rem call dll( dll_gdi32,"DeleteDC",hdc ) dim G_NEWCOM$(100) Rem call dll( dll_gdi32,"BitBlt",hDestDC , x , y , nWidth , nHeight , hSrcDC , xSrc , ySrc , dwRop ) dim IDXCOM(100) Rem call dll( USER32_DLL,"ReleaseCapture",) type attribute_table Rem call dll( USER32_DLL,"ClientToScreen",hwnd , lpPoint As POINTAPI) name as string Rem mask as integer Rem Get user name endtype Rem call dll( dll_advapi32.dll,"GetUserNameA",lpBuffer , nSize ) call dll(GetUserName dll_advapi32.dll,"GetUserNameA",lpBuffer , nSize ) dim att_table(10)as attribute_table Rem type VS_VERSION Rem Get computer name vstype as integer Rem call dll( KERNEL32_DLL,"GetComputerNameA",lpBuffer , nSize ) call dll(GetComputerName KERNEL32_DLL,"GetComputerNameA",lpBuffer , nSize ) name as string Rem mask as DWORD Rem Get volume name/serial# endtype Rem call dll( KERNEL32_DLL,"GetVolumeInformationA",lpRootPathName , lpVolumeNameBuffer , nVolumeNameSize rem , lpVolumeSerialNumber , lpMaximumComponentLength , lpFileSystemFlags , lpFileSystemNameBuffer , nFileSystemNameSize ) Rem dim VS_table(64)as VS_VERSION Rem Identify drive type Rem call dll( KERNEL32_DLL,"GetDriveTypeA",nDrive ) Rem ********************************************************************** Rem Rem * collect display data * Rem Get free space Rem ********************************************************************** Rem call dll( KERNEL32_DLL,"GetDiskFreeSpaceA",lpRootPathName , lpSectorsPerCluster , lpBytesPerSector rem , lpNumberOfFreeClusters , lpTotalNumberOfClusters ) Rem cur_window_height=get display height() Rem INI editing cur_screen_width=screen width() Rem call dll( KERNEL32_DLL,"WritePrivateProfileSectionA",lpAppName , lpString , lpFileName ) cur_screen_height=screen height() Rem call dll( KERNEL32_DLL,"WritePrivateProfileStringA",lpApplicationName , lpKeyName As Any, lpString As Any, lpFileName ) cur_screen_depth=screen depth() Rem call dll( KERNEL32_DLL,"GetPrivateProfileIntA",lpApplicationName , lpKeyName , nDefault , lpFileName ) Rem call dll( KERNEL32_DLL,"GetPrivateProfileSectionA",lpAppName , lpReturnedString , nSize , lpFileName ) Rem *********************************************************************** Rem call dll( KERNEL32_DLL,"GetPrivateProfileStringA",lpApplicationName , lpKeyName As Any, lpDefault , lpReturnedString , nSize , lpFileName ) Rem * set fonts and display * Rem Rem *********************************************************************** Rem Put icon in system tray perform checklist for display modes Rem call dll( USER32_DLL,"CallWindowProcA",lpPrevWndFunc , hWnd , Msg , wParam , lParam ) for c=1 to checklist quantity() Rem call dll( USER32_DLL,"GetWindowLongA",hwnd , nIndex ) width=checklist value a(c) Rem call dll( USER32_DLL,"SetWindowLongA",hwnd , nIndex , dwNewLong ) height=checklist value b(c) Rem call dll( SHELL32_DLL.dll," Shell_NotifyIconA",dwMessage , lpData ) depth=checklist value c(c) Rem call dLL( KERNEL32_DLL,"RtlMoveMemory",Destination , Source, Length ) next c Rem call dll( USER32_DLL,"DrawEdge",hdc , qrc As RECT, edge , grfFlags ) if width > 800 then width=800:height=600 Rem set display mode width, height, depth Rem Wait for program to stop hide window Rem call dll( KERNEL32_DLL,"CreateProcessA",lpApplicationName , lpCommandLine rem , lpProcessAttributes As SECURITY_ATTRIBUTES rem , lpThreadAttributes As SECURITY_ATTRIBUTES, bInheritHandles rem , dwCreationFlags , lpEnvironment As Any, lpCurrentDriectory rem , lpStartupInfo As STARTUPINFO rem , lpProcessInformation As PROCESS_INFORMATION)set window title C_program Rem call dll( KERNEL32_DLL,"WaitForSingleObject",hHandle , dwMilliseconds ) set window layout 1,1,1 Rem set window size width,height Rem Stop ctrl-alt-del set window position 10,10 Rem call dll( USER32_DLL,"SystemParametersInfoA",uAction , uParam , ByRef lpvParam , fuWinIni ) Rem Rem **************************************************************************** Rem * GLOBAL program constant start with C_ * Rem **************************************************************************** #constant C_project "New_standard1" #constant C_copyright "copyright (c) WKSControls" #constant C_version "09/30/2003" #constant C_programer "Walter K. Sheets" #constant C_program "New_standard1" #constant C_crlf chr$(10)+chr$(13) #constant C_PI 3.142857143 #constant C_e_natural_log 2.71828 #constant C_on 255 #constant C_off 0 #constant C_True 255 #constant C_False 0 #constant C_MAX_PATH 260 Rem **************************************************************************** Rem * Macros all micro start with M_ * Rem **************************************************************************** #constant M_DEBUG_WAIT print "debug here====>":wait key #constant M_LOAD_DLL IF not dll exist(DLL_NUMBER) THEN load dll G_DLL_TABLE$(DLL_NUMBER) ,DLL_NUMBER #constant M_DELETE_DLL IF dll exist(DLL_NUMBER) THEN DELETE DLL DLL_NUMBER #constant M_DETAIL G_DETAIL=255 #constant M_WAIT_USER wait 1000:show window:while mouseclick():endwhile:while len(inkey$()):endwhile:print "Any key to continue" : while len(inkey$())=0 and mouseclick()=0 :endwhile #constant M_DETAIL_OUTPUT print #constant M_debuglog disable debuglog rem To use logging rem the 3 lines above and un-remark the next 3 lines rem #constant M_debuglog enable debuglog : clear debuglog : debuglog get date$() : debuglog get time$() rem #constant M_WAIT_USER rem rem #constant M_DETAIL_OUTPUT debuglog Hide window Rem **************************************************************************** Rem * Global note Global commands are upper case, my convention only * Rem **************************************************************************** Global G_APPDIR$ : ` The directory which the executeable is ran from Global G_APPFILE$ : ` The programs name Global G_DBPDIR$ : ` The Home directoy of Dark Basic professional Global G_PLUGINSUSER$ : ` The compiler\plugins-users under Dark Basic professional Global G_CURDIR$ : ` The dir the executable is ran from Global G_LIBDIR$ : ` The libary subdirectoy under Dark Basic professional Global G_WORKDIR$ : ` The command subdirectoy under Dark Basic professional Global G_HELPDIR$ : ` The help subdirectoy under Dark Basic professional Global G_DLLDIR$ : ` The DLLs subdirectoy under Dark Basic professional Global G_INIFILE$ : ` The drice:\path\filename.ini file to be use by this program Global G_WINTEMP$ : ` The temp directory of windows OS Global G_WINDOW_ENABLE : Global G_TMEM : Global G_DMEM : Global G_SMEM : Global G_ERROR_CODE : Global G_DETAIL : Global G_SCREEN_COLOR : Global G_FONT_FOREGROUND : Global G_FONT_BACKGROUND : Rem *************************************************************************** Rem * PRESET Global note Global commands are upper case, my convention only Rem *************************************************************************** G_APPDIR$=get dir$() G_APPFILE$=APPNAME$() G_DBPDIR$=GET REGISTRY$("SOFTWARE\Dark Basic\Dark Basic Pro","INSTALL-PATH")+"\" G_WINTEMP$=GET REGISTRY$("SYSTEM\ControlSet001\Control\Session Manager\Environment","TEMP") G_LIBDIR$=G_DBPDIR$+"libary\" G_HELPDIR$=G_DBPDIR$+"help\" G_DLLDIR$=G_DBPDIR$+"DLLs\" G_PLUGINSUSER$=G_DBPDIR$+"compiler\plugins-user\" G_TMEM=system tmem available() G_DMEM=system dmem available() G_SMEM=int(abs(system smem available())) `+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ `+ Build File Atribute Table + `+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ REM THE following section used by THE GetFileAttributes FUCTION ONLY Rem Rem Rem TYPE FILETTIME Rem DWLOWDATETIME AS LONG Rem dwHIGHDATETIME AS LONG Rem ENDTYPE Rem Rem Type WIN32_FIND_DATA | | TYPE WIN32FINDDATA Rem dwFileAttributes As Long | dwFileAttributes 0 `4 | def dwFileAttributes as UINT Rem ftCreationTime As FILETIME | ftcreationtime 4 `8 | def ftCreationTime as UINT64 Rem ftLastAccessTime As FILETIME | ftlastacesstime 12 `8 | def ftLastAccessTime as UINT64 Rem ftLastWriteTime As FILETIME | ftLastWriteTime 20 `8 | def ftLastWriteTime as UINT64 Rem nFileSizeHigh As Long | nfileSizehigh 28 `4 | def fileSizeH as UINT Rem nFileSizeLow As Long | nFileSizeLow 32 `4 | def fileSizeL as UINT Rem dwReserved0 As Long | dwReserved0 36 `4 | Rem dwReserved1 As Long | dwReserved1 40 `4 | def reserved as UINT64 Rem cFileName As String * MAX_PATH | cfilename 44 `260 | def cFileName[ 260 ] as CHAR Rem cAlternate As String * 14 | calternate 304 `14 | def cAlternateFileName[ 14 ] as CHAR Rem EndType | structend 318 | ENDTYPE Rem Rem The dwFileAttributes has the following attribute values that are bit-wise Or-ed to gather to get information about the given file. Rem Rem FILE_ATTRIBUTE_ARCHIVED - File has been archived = &H20 Rem FILE_ATTRIBUTE_COMPRESSED - object is compressed = &H800 Rem FILE_ATTRIBUTE_DIRECTORY - object is an directory = &H10 Rem FILE_ATTRIBUTE_HIDDEN - object is hidden = &H2 Rem FILE_ATTRIBUTE_NORMAL - all other attributes don't apply. Normal file. = &H80 Rem FILE_ATTRIBUTE_OFFLINE - object has been moved to off-line storage Rem FILE_ATTRIBUTE_READONLY - object has read-only permissions = &H1 Rem FILE_ATTRIBUTE_SYSTEM - OS file or being used by OS = &H4 Rem FILE_ATTRIBUTE_TEMPERORY - temporary file = &H100 Rem A value of FILE_ATTRIBUTE_NORMAL can not be used with any other flag. Rem G_nFileSizeHigh - holds the high 32 bits of a given 64 bit file size Rem Rem G_nFileSizeLow - holds the low 32 bits of a given 64 bit file size. Rem Rem G_cFileName - holds the long file name of object Rem Rem G_cAlternateFileName - holds the 8.3 DOS file name format, only if cFileName holds a long file name. Rem Rem G_ftCreationTime - returns the Creation time of object Rem Rem G_ftLastAccessTime - returns the last access time of object Rem Rem G_ftLastWriteTime - returns the last write time of object Rem type attribute_table name as string mask as integer endtype Dim G_att_table(10)as attribute_table G_att_table(1).name="ARCHIVE" : G_att_table(1).mask=0x020 G_att_table(2).name="COMPRESSED" : G_att_table(2).mask=0x800 G_att_table(3).name="DIRECTORY" : G_att_table(3).mask=0x010 G_att_table(4).name="HIDDEN" : G_att_table(4).mask=0x002 G_att_table(5).name="NORMAL" : G_att_table(5).mask=0x080 G_att_table(6).name="READONLY" : G_att_table(6).mask=0x001 G_att_table(7).name="SYSTEM" : G_att_table(7).mask=0x004 G_att_table(8).name="TEMPORARY" : G_att_table(8).mask=0x100 G_att_table(9).name="spare1" : G_att_table(8).mask=0x000 G_att_table(10).name="spare2" : G_att_table(8).mask=0x000 GLOBAL G_WFD_PTR G_wfd_ptr=make memory(318) Rem WFD tablestructure Global G_ATTRIBUTE_FILENAME$ Global G_dwFileAttributes_ptr :`4 Global G_ftcreationtime_ptr :`8 Global G_ftlastacesstime_ptr :`8 Global G_ftLastWriteTime_ptr :`8 Global G_nfileSizehigh_ptr :`4 Global G_nFileSizeLow_ptr :`4 Global G_dwReserved0_ptr :`4 Global G_dwReserved1_ptr :`4 Global G_cfilename_ptr :`260 Global G_calternate_ptr :`14 rem WFD_structure end=31 |