HELP FOR A TEST TO ALLOW APPLICATIONS

HELP FOR A TEST TO ALLOW APPLICATIONS

Postby Silvio » Mon Nov 29, 2010 11:21 am

I wish to allow some applications to final user
and I saw We can set the application into Registry of Windows
on this page http://www.pctools.com/guides/registry/detail/113/



With the command oREg:set we can set the value

Sample :

If I insert 3 applications :

Winword.exe
Excel.exe
Powerpoint.exe

the test I made insert on registry only the last applications.. why ?



I MAKE THIS SMALL TEST

Code: Select all  Expand view

#include "fivewin.ch"


#define HKEY_CURRENT_USER   -2147483647  // 2147483649




STATIC aFiles := {}, oFiles  


// TEST TO ALLOW AND RECSTRICT APPLICATIONS TO USER
 // SEE here http://www.pctools.com/guides/registry/detail/113/

Function Test()
  LOCAL cVar, oLbx4  
  Local odlg,oBtn[3]


DEFINE DIALOG oDLG SIZE 350,390 TITLE " TEST ALLOW  APPLICATIONS"

 @ 3,5 LISTBOX oLbx4  VAR cVar ITEMS aFiles size 140,120  OF oDlg PIXEL


      @120, 10 BUTTON oBtn[1] PROMPT "&Add" ;
             SIZE 37, 11 PIXEL OF oDlg ACTION SelFiles(oLbx4)

      @120, 100 BUTTON oBtn[2] PROMPT "&Canc" ;
             SIZE 37, 11 PIXEL OF oDlg ACTION DeleteFile(oLbx4)

  @135, 10 BUTTON oBtn[3] PROMPT "&Set to Registry " ;
             SIZE 37, 11 PIXEL OF oDlg ACTION User_applicativi(oLbx4,aFiles)

ACTIVATE DIALOG  oDlg


RETURN NIL





Function SelFiles(oLbx4 )

local cFiles, i, cName, lEnd := .F., j, cDir

cFiles := CGETFILE("All | *.exe" ,"Seleziona i programmi da usare", "*.exe", "C:\", .f., .T., 512 )

if EMPTY( cFiles )
  RETURN NIL
endif

i := strcharcount( cFiles, "
" )

if i > 0

   cDir := ALLTRIM( StrToken( cFiles, 1 ,"
" ) )

   for j = 2 to i
       cName := ALLTRIM( StrToken( cFiles, j ,"
" ) )
       AADD( aFiles, cDir+cName )
   next j
     cName := ALLTRIM( SUBSTR( cFiles, RAT("
",cFiles), LEN( cFiles ) ) )
     AADD( aFiles, cDir+cName )
else
     AADD( aFiles, cFiles )
endif
  oLbx4:SetItems( aFiles )
  oLbx4:SetFocus()
return nil





 FUNCTION DeleteFile(oLbx4)
 IF LEN( aFiles ) == 0
   MSGSTOP("
Nessun file da cancellare")
   RETURN NIL
 ENDIF
   ADEL( aFiles, oLbx4:GetPos() )
   ASIZE( aFiles, LEN( aFiles ) - 1 )
   oLbx4:SetItems( aFiles )
   oLbx4:SetFocus()
RETURN NIL







Function User_applicativi(oLbx4,aFiles)
            Local nHandle
            Local oReg
            Local key:="
"
            Local name:=0
            Local valore:="
"
            Local  cIniFile := cFilePath( GetModuleFileName( GetInstance() ) ) + NOME_FILE_INI



    key :="
Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\RestrictRun"

   // name :="
RestrictRun"    //abilitazione programmi
   //Local name :="
DisallowRun"  disabilitazione programmi

           for n := 1 to len( afiles)
                        name:=n
                        valore:=afiles[n]

              IF RegOpenKeyex( HKEY_CURRENT_USER,Key, @nHandle ) == 0
                       oReg:Set(name,valore)
                ELSE

                 oReg:= TReg32():New(HKEY_CURRENT_USER, Key)
                 oReg:Create( HKEY_CURRENT_USER,Key )
                        oReg:Set(Name,valore)
                 ENDIF
              NEXT

retur nil








if you go to registry at this key

Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\RestrictRun

you can see only the last set and not all applications

perhaps there is an error but I not Found it

CAN YOU HELP ME PLEASE ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: HELP FOR A TEST TO ALLOW APPLICATIONS

Postby Silvio » Mon Nov 29, 2010 1:10 pm

resolved !!!
sorry
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: HELP FOR A TEST TO ALLOW APPLICATIONS

Postby Carles » Mon Nov 29, 2010 2:58 pm

Silvio

Then u can post it :D
Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
Skype -> https://join.skype.com/cnzQg3Kr1dnk
User avatar
Carles
 
Posts: 1134
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona

Re: HELP FOR A TEST TO ALLOW APPLICATIONS

Postby Silvio » Tue Nov 30, 2010 8:00 am

I try on my computer the code run ok
it insert application link on registry by my exe

but then when I shutdown the pc the window allow any applications and not only the applications I insert on registry

this the code I corrected

Code: Select all  Expand view



Function User_applicativi(oLbx4,aFiles)
            Local nHandle
            Local oReg
            Local key:=""
            Local keyReg:=""
            Local name:=0
            Local valore:=""
            Local  cIniFile := cFilePath( GetModuleFileName( GetInstance() ) ) + NOME_FILE_INI
            Local oKeyReg
            local n
            Local cApplication:=""
            oLbx4:GoTop()



            key_Reg :="Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\RestrictRun"

                      IF RegOpenKeyex( HKEY_CURRENT_USER,Key_reg, @nHandle ) == 0
                         oKeyReg:= TReg32():New(HKEY_CURRENT_USER, Key_Reg)

                         FOR n=1 to  len( afiles)
                                Key_val :="Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\RestrictRun\"
                                cApplication:=afiles[n]
                                    IF RegOpenKeyex( HKEY_CURRENT_USER,Key_val, @nHandle ) == 0
                                       oReg:Set(alltrim(str(n)),cApplication)
                                    ELSE
                                       oReg:= TReg32():New(HKEY_CURRENT_USER, Key_val)
                                       oReg:Create( HKEY_CURRENT_USER,Key_val )
                                       oReg:Set(alltrim(str(n)),cApplication)
                                  ENDIF
                          NEXT
                ELSE


                         oKeyReg:= TReg32():New(HKEY_CURRENT_USER, Key_Reg)
                         oKeyReg:Create( HKEY_CURRENT_USER,key_Reg )

                         FOR n=1 to  len( afiles)
                                Key_val :="
Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\RestrictRun\"
                                cApplication:=afiles[n]
                                    IF RegOpenKeyex( HKEY_CURRENT_USER,Key_val, @nHandle ) == 0
                                       oReg:Set(alltrim(str(n)),cApplication)
                                    ELSE
                                       oReg:= TReg32():New(HKEY_CURRENT_USER, Key_val)
                                       oReg:Create( HKEY_CURRENT_USER,Key_val )
                                       oReg:Set(alltrim(str(n)),cApplication)
                                    ENDIF
                         NEXT
                 ENDIF




               


        RETURN NIL


If you try it run ok : it insert any application on registry
when you shutdown the pc then it not run ok
please can you help me ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: HELP FOR A TEST TO ALLOW APPLICATIONS

Postby Silvio » Tue Nov 30, 2010 8:18 am

for sample I try with

1 mspaint.exe

or I try with

1 c:\windows\system32\mspaint.exe


NOT RUN !!!

the use can use this application
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: HELP FOR A TEST TO ALLOW APPLICATIONS

Postby Silvio » Tue Nov 30, 2010 8:48 am

Carles,
ok I understood

NOW RUN

we need made all this I make but we must add on key

"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"
one variables DWORD

RestrictRun value 1

and now run ok on XP PROFESIONAL

PLEASE do you want try and see pn wich system it run ok ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: HELP FOR A TEST TO ALLOW APPLICATIONS

Postby Carles » Tue Nov 30, 2010 1:49 pm

Silvio thanks for u explanation :-)
Salutacions, saludos, regards

"...programar es fácil, hacer programas es difícil..."

UT Page -> https://carles9000.github.io/
Forum UT -> https://discord.gg/bq8a9yGMWh
Skype -> https://join.skype.com/cnzQg3Kr1dnk
User avatar
Carles
 
Posts: 1134
Joined: Fri Feb 10, 2006 2:34 pm
Location: Barcelona


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 80 guests