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 ?