SaveBuffer of screencapture on desktop (path)
Blitz3D Forums/Blitz3D Programming/SaveBuffer of screencapture on desktop (path)
| ||
| Hi there, does anyone know how to save a screencapture on the "desktop"? I use SaveBuffer (BackBuffer(), "temp.bmp") Anything get out from SystemProperty (property$)? I have seen some dos code as: %HOMEDRIVE% => c: %HOMEPATH% => \Documents and Settings\{username} %USERPROFILE% => C:\Documents and Settings\{username} (ref: http://vlaurie.com/computers2/Articles/environment.htm) but i do not know how to reach the path location using Blitz3d commands... Any Suggestion? thanks indeed, cheers, jTassinari Last edited 2010 |
| ||
| Using the environment varables such as %USERPROFILE% works within B3D and is better (compatible with different Windows versions like Vista, 7) than just "C:\Documents and Settings\" etc. So the path for the current user's desktop is: "%USERPROFILE%\Desktop\" Alternatively, there's "%ALLUSERSPROFILE%\Desktop\" if you wanted the 'shared' desktop which is available to all users. |
| ||
| thanks man, i try and test it =) cheers, jTassinari |
| ||
| Alternatively, in the code archives, there is this lib which can retreive the locations of several 'special folders'. I'm not sure if \Desktop could be used on non-English versions of Windows. http://www.blitzbasic.com/Community/posts.php?topic=49838 |
| ||
| That's a good point, Warner. Alternatively the display name for "Desktop" (and the path in fact)could be read from the Registry? If you're going to go the DLL route, then I recommend using SHGetSPecialFolderPath() rather than the relative location one, especially since the Desktop is ALWAYS the root of the namespace. Const CSIDL_DESKTOP = 0
Const CSIDL_INTERNET = 1
Const CSIDL_PROGRAMS = 2
Const CSIDL_CONTROLS = 3
Const CSIDL_PRINTERS = 4
Const CSIDL_PERSONAL = 5
Const CSIDL_FAVORITES = 6
Const CSIDL_STARTUP = 7
Const CSIDL_RECENT = 8
Const CSIDL_SENDTO = 9
Const CSIDL_BITBUCKET = 16
Const CSIDL_STARTMENU = 17
Const CSIDL_NETWORK = 18
Const CSIDL_NETHOOD = 19
Const CSIDL_FONTS = 20
Const CSIDL_TEMPLATES = 21
Const CSIDL_COMMON_STARTMENU = 22
Const CSIDL_COMMON_PROGRAMS = 23
Const CSIDL_COMMON_STARTUP = 24
Const CSIDL_COMMON_DESKTOPDIRECTORY = 25
Const CSIDL_APPDATA = 26
Const CSIDL_PRINTHOOD = 27
Const CSIDL_LOCAL_APPDATA = 28
Const CSIDL_ALTSTARTUP = 29
Const CSIDL_COMMON_ALTSTARTUP = 30
Const CSIDL_COMMON_FAVORITES = 31
Const CSIDL_INTERNET_CACHE = 32
Const CSIDL_COOKIES = 33
Const CSIDL_HISTORY = 34
Const CSIDL_COMMON_APPDATA = 35
Const CSIDL_WINDOWS = 36
Const CSIDL_SYSTEM = 37
Const CSIDL_PROGRAM_FILES = 38
Const CSIDL_MYPICTURES = 39
Const CSIDL_PROFILE = 40
Const CSIDL_SYSTEMX86 = 41
Const CSIDL_PROGRAM_FILESX86 = 42
Const CSIDL_PROGRAM_FILES_COMMON = 43
Const CSIDL_PROGRAM_FILES_COMMONX86 = 44
Const CSIDL_COMMON_TEMPLATES = 45
Const CSIDL_COMMON_DOCUMENTS = 46
Const CSIDL_COMMON_ADMINTOOLS = 47
Const CSIDL_ADMINTOOLS = 48
Const CSIDL_CONNECTIONS = 49
Const CSIDL_FLAG_CREATE = 32768
Const CSIDL_FLAG_DONT_VERIFY = 16384
Const CSIDL_FLAG_MASK = 65280
Const CSIDL_DESKTOPDIRECTORY = $10
Const CSIDL_DRIVES = $11
Const MAX_PATH%=512
Print GetSpecialFolderPath()
Function GetSpecialFolderPath$(CSIDL%=0)
Local bPathBank%=CreateBank(4)
Local bInBank%=CreateBank(4)
PokeInt(bInBank,0,CSIDL)
CallDLL ("Shell32","SHGetSpecialFolderLocation",bInBank,bPathBank)
FreeBank bInBank
Local nIDList%=PeekInt(bPathBank,0)
FreeBank bPathBank
Local sReturn$=""
If (nIDList)
Local bIDBank%=CreateBank(MAX_PATH)
PokeInt(bIDBank,0,nIDList)
Local bReturnBank%=CreateBank(MAX_PATH)
Local Valid%=CallDLL("Shell32","SHGetPathFromIDList",bIDBank,bReturnBank)
If (Valid) Then sReturn=peekstring(bPathBank);PeekString(bReturnBank)
FreeBank bIDBank
End If
Return sReturn$
End Function
Function PeekString$(bBank%,nOffset%=0)
Local sReturn$=""
Local Size%=BankSize(bBank)
If ((Size)*(nOffset<(Size+1)))
Local IterBytes%
Local Byte%
For IterBytes=nOffset To Size-1
Byte=PeekByte(bBank,IterBytes)
If (Byte)
sReturn = sReturn + Chr$(Byte)
Else
Exit
End If
Next
End If
Return sReturn$
End Function
|