DroopyLib

Developed or developing a new product in PureBasic? Tell the world about it.
jpd
Enthusiast
Enthusiast
Posts: 167
Joined: Fri May 21, 2004 3:31 pm

Re: DroopyLib

Post by jpd »

Hi Droopy,

thank you very much for maintain and updating this library, this is securely a hard and time-consuming job.

Best
jpd
PB 5.10 Windows 7 x64 SP1
SeregaZ
Enthusiast
Enthusiast
Posts: 617
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: DroopyLib

Post by SeregaZ »

Dear Droopy, i have a small problem with RegGetValue (and probably with RegSetValue) function. for explorer 8 and hier windows registry have some special type of variable - REG_MULTI_SZ
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main "Secondary Start Pages" - for example

how to make RegGetValue and RegSetValue works with this type of variable?
SeregaZ
Enthusiast
Enthusiast
Posts: 617
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: DroopyLib

Post by SeregaZ »

i see in source of droopy how to read #REG_BINARY type - so i think #REG_MULTI_SZ almost same thing.

Code: Select all

        Case #REG_MULTI_SZ
          BinaryBytes=1024
          *RegBinary=AllocateMemory(BinaryBytes) 
          GetHandle = RegQueryValueEx_(hKey, ValueName, 0, @lType, *RegBinary, @BinaryBytes) 
          If GetHandle = 0 ; SUCCESs
            GetValue=""
            For i = 0 To (BinaryBytes-1 )
              Temp3=PeekB(*RegBinary+i)&$000000FF
              If Temp3<16 : GetValue+"0" : EndIf
              Debug Hex(Temp3)
              GetValue+ Hex(Temp3)
            Next 
            FreeMemory(*RegBinary)
          EndIf 
how to make Temp3=PeekB(*RegBinary+i)&$000000FF to read 4 symbols, not 2 how read it now? then convert this 4 symbols to letter like: 68 00 - h, 74 00 - t, and etc
Korolev Michael
Enthusiast
Enthusiast
Posts: 199
Joined: Wed Feb 01, 2012 5:30 pm
Location: Russian Federation

Re: DroopyLib

Post by Korolev Michael »

DroopyLib 5.11.001 fails at PB 5.20 Beta 10, because "Misc" library is missing. This library was renamed to "System".
Former user of pirated PB.
Now registered user :].
SeregaZ
Enthusiast
Enthusiast
Posts: 617
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: DroopyLib

Post by SeregaZ »

Code: Select all

*Start of Code
#DEFINE HKEY_LOCAL_MACHINE   -2147483646

LOCAL nKey, cSubKey, cValue, nStrings, acValueRead, nLoopVar
nKey = HKEY_LOCAL_MACHINE
cSubKey = "Software\VfpRegTest"
cValue = "TestREG_MULTI_SZ"

nStrings = ReadREG_MULTI_SZ(nKey, cSubKey, cValue, @acValueRead)
IF (nStrings > 0) THEN
   =MESSAGEBOX("Function Successful.")
   FOR nLoopVar = 1 TO nStrings
      ? acValueRead(nLoopVar)
   ENDFOR	
ELSE
   =MESSAGEBOX("Function Not Successful.")
ENDIF

FUNCTION ReadREG_MULTI_SZ
* This function reads a REG_MULTI_SZ value from the registry. It will return
* the number of Elements in acValueRead if successful and store the 
* strings in acValueRead. If not successful, it will return 0 and 
* acValueRead will contain 0 elements
   PARAMETERS  nKey, cSubKey, cValue,  acValueRead
   * nKey The root key to open. It can be any of the constants defined below
   *  #DEFINE HKEY_CLASSES_ROOT           -2147483648
   *  #DEFINE HKEY_CURRENT_USER           -2147483647
   *  #DEFINE HKEY_LOCAL_MACHINE          -2147483646
   *  #DEFINE HKEY_USERS                  -2147483645
   * cSubKey The SubKey to open.
   * cValue The value that is going to be read.
   * acValueRead Array of strings read from the registry.

   * Constants that are needed for Registry functions
   #DEFINE REG_MULTI_SZ                 7

   * WIN 32 API functions that are used
   DECLARE Integer RegOpenKey IN Win32API ;
      Integer nHKey, String @cSubKey, Integer @nResult
   DECLARE Integer RegQueryValueEx IN Win32API ;
      Integer nHKey, String lpszValueName, Integer dwReserved,;
      Integer @lpdwType, String @lpbData, Integer @lpcbData
   DECLARE Integer RegCloseKey IN Win32API Integer nHKey

   * Local variables used
   LOCAL nErrCode      && Error Code returned from Registry functions
   LOCAL nKeyHandle    && Handle to Key that is opened in the Registry
   LOCAL lpdwValueType && Type of Value that we are looking for
   LOCAL lpbValue      && The data stored in the value
   LOCAL lpcbValueSize && Size of the variable
   LOCAL lpdwReserved  && Reserved Must be 0
   LOCAL lNotDone      && Used to Exit Loop
   LOCAL nOccurance    && The occurrence of CHR(0) in the string
   LOCAL nPrevPos      && Previous element in Array 
   LOCAL nCurrPos      && Current element in Array being processed
   LOCAL nElements     && Number of Elements in the Array
   
   * Initialize the variables
   nKeyHandle = 0
   lpdwReserved = 0           
   lpdwValueType = REG_MULTI_SZ
   lNotDone = .T.
   nOccurance = 1
   nPrevPos = 1
   nElements = 0

   nErrCode = RegOpenKey(nKey, cSubKey, @nKeyHandle)
   * If the error code isn't 0, then the key doesn't exist or can't be opened.
   IF (nErrCode # 0) THEN
      RETURN 0
   ENDIF

   lpbValue = ""
   lpcbValueSize = 1 
   * Get the size of the data in the value
   nErrCode=RegQueryValueEx(nKeyHandle, cValue, lpdwReserved, @lpdwValueType, @lpbValue, @lpcbValueSize)

   * Make the buffer big enough
   lpbValue = SPACE(lpcbValueSize)   
   nErrCode=RegQueryValueEx(nKeyHandle, cValue, lpdwReserved, @lpdwValueType, @lpbValue, @lpcbValueSize)
   
   =RegCloseKey(nKeyHandle)
   IF (nErrCode # 0) THEN
      RETURN 0
   ENDIF

   * This loop fills an array with the strings stored in the registry
   DO WHILE lNotDone
      nCurrPos = AT(CHR(0), lpbValue, nOccurance)  && CHR(0) is used to separate lines in the registry
      IF ((nCurrPos > 0) AND (nCurrPos < lpcbValueSize)) THEN
         nElements = nElements + 1
         DIMENSION acValueRead(nElements)
         acValueRead(nElements) = SUBSTR(lpbValue, nPrevPos, nCurrPos - nPrevPos)
         nPrevPos = nCurrPos + 1
         nOccurance = nOccurance + 1
      ELSE
         lNotDone = .F.
      ENDIF
   ENDDO
RETURN nElements
* End of Code
where in this code is convert 4 symbols to letter?
Korolev Michael
Enthusiast
Enthusiast
Posts: 199
Joined: Wed Feb 01, 2012 5:30 pm
Location: Russian Federation

Re: DroopyLib

Post by Korolev Michael »

@SeregaZ, what?
Former user of pirated PB.
Now registered user :].
SeregaZ
Enthusiast
Enthusiast
Posts: 617
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: DroopyLib

Post by SeregaZ »

я так полагаю, что эта функция производит чтение реестра данного типа, следовательно там должна быть функция по конвертированию кода символа в сам символ, то есть 68 00 - h, 74 00 - t и так далее. вот собственно какая часть кода это делает?
User_Russian
Addict
Addict
Posts: 1443
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: DroopyLib

Post by User_Russian »

Так это же юникод.
Компилируй программу с поддержкой юникода.

Code: Select all

String.s="ht"
ShowMemoryViewer(@String, StringByteLength(String, #PB_Unicode))
SeregaZ
Enthusiast
Enthusiast
Posts: 617
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: DroopyLib

Post by SeregaZ »

то, да не то :)
в итоге показывает как: 68 74 00 00, а в реестре так: 68 00 74 00 и это получается надо использовать для записи в реестр, а мне пока надо обратную операцию - для чтения. есть код 68 00 - его надо в букву. и как лучше это сделать? сразу по "поймал" 4 символа и переводить в букву, или можно как-то итоговое значение конвертануть?
(запись я пока делать боюсь, так как думаю испорчу свой реестр)

вот например ничего городить не надо, просто #REG_MULTI_SZ читать точно также как и #REG_SZ, но тут проблема - он читает до первых нулей 00 00, а эти нули это по сути переход на новую строку в случае когда в качестве домашней страницы указаны более двух сайтов. например:
Image
тут видно, что мой код читает только одну ссылку вместо двух. то есть код дошел до 00 00, посчитал концом строки и не стал читать далее.

итоговое значение выглядит так:
68007400740070003A002F002F003100320037002E0030002E0030002E0031002F00000068007400740070003A002F002F003100320037002E0030002E0030002E0031002F00000000
Last edited by SeregaZ on Tue Aug 20, 2013 9:33 am, edited 1 time in total.
User avatar
Bisonte
Addict
Addict
Posts: 1226
Joined: Tue Oct 09, 2007 2:15 am

Re: DroopyLib

Post by Bisonte »

Hey guys... come back to english... !
PureBasic 6.04 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
SeregaZ
Enthusiast
Enthusiast
Posts: 617
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: DroopyLib

Post by SeregaZ »

Bisonte my language not very well, so some people dont understand what i am talking about. but when truth will be found - i will translate that topic :)
Last edited by SeregaZ on Tue Aug 20, 2013 5:15 pm, edited 1 time in total.
User_Russian
Addict
Addict
Posts: 1443
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: DroopyLib

Post by User_Russian »

SeregaZ wrote:то, да не то :)
Моя твоя не понимать. :D :wink:

Давай лучше перенесем обсуждение на наш форум.
SeregaZ
Enthusiast
Enthusiast
Posts: 617
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: DroopyLib

Post by SeregaZ »

User_Russian wrote:Моя твоя не понимать. :D :wink:
i get from registry this (из реестра получил это значение):
68007400740070003A002F002F003100320037002E0030002E0030002E0031002F00000068007400740070003A002F002F003100320037002E0030002E0030002E0031002F00000000

how to convert this to urls? (как его перевести в буквы, точнее ссылки?)
User_Russian
Addict
Addict
Posts: 1443
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: DroopyLib

Post by User_Russian »

Search for 4 zero bytes and divide string on them (Ищи 4 нулевых байта и разделяй строки по ним).
SeregaZ
Enthusiast
Enthusiast
Posts: 617
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: DroopyLib

Post by SeregaZ »

где именно разделяется это я и сам понимаю. мой вопрос не совсем понятен что-ли не пойму? третий раз напишу какой командой производить перевод 6800 в букву? буква в код понятно, мне нужна обратная операция.
Post Reply