Code: Select all
; Return Values
; 0 [NOT_IN_DROPBOX] ==> Folder is not in Dropbox
; 1 [UP_TO_DATE] ==> Up to Date
; 2 [SYNCHRONIZING] ==> Sync in Progress
; 99 [NOT_RUNNING] ==> Dropbox is not running
MsgBox % GetDropboxStatus("C:\Users\" A_UserName "\Dropbox") ; ==> return e.g. 1
MsgBox % GetDropboxStatus("C:\Users\" A_UserName "\Dropbox", 1) ; ==> return e.g. UP_TO_DATE ;
GetDropboxStatus(DBLocation, StatusToText := 0)
{
static DBStatusTxt := {0: "NOT_IN_DROPBOX", 1: "UP_TO_DATE", 2: "SYNCHRONIZING", 99 : "NOT_RUNNING"}
static RequestInfo := 0x3048302
static ProcessId := DllCall("kernel32.dll\GetCurrentProcessId")
static ThreadId := DllCall("kernel32.dll\GetCurrentThreadId")
static RequestType := 1
Process, Exist, % "Dropbox.exe"
if !(ErrorLevel)
return StatusToText ? DBStatusTxt[99] : 99
if !(DllCall("kernel32.dll\ProcessIdToSessionId", "UInt", ProcessId, "UInt*", SessionId))
return "*ProcessIdToSessionId [" DllCall("kernel32.dll\GetLastError") "]"
PipeName := "\\.\pipe\DropboxPipe_" SessionId
SizeIn := VarSetCapacity(BuffIn, 16 + 524)
, NumPut(RequestInfo, BuffIn, 0, "Int"), NumPut(ProcessId, BuffIn, 4, "Int")
, NumPut(ThreadId, BuffIn, 8, "Int"), NumPut(RequestType, BuffIn, 12, "Int")
, StrPut(DBLocation, &BuffIn + 16, 524//2, "UTF-16")
SizeOut := VarSetCapacity(BuffOut, 16382, 0)
if !(DllCall("kernel32.dll\CallNamedPipe", "Str", PipeName, "Ptr", &BuffIn, "UInt", SizeIn, "Ptr", &BuffOut, "UInt", SizeOut, "UInt*", BytesRead, "UInt", 1000))
return "*CallNamedPipe [" DllCall("kernel32.dll\GetLastError") "]"
return StatusToText ? DBStatusTxt[StrGet(&BuffOut + 4, BytesRead - 5, "CP0")] : StrGet(&BuffOut + 4, BytesRead - 5, "CP0")
}