Pas de problème (pb), que du PowerBuilder (PB) ^^

Le forum (ô combien francophone) des utilisateurs de Powerbuilder.

Recherche rapide

Annonce

Certaines rubriques, dont des cours, sont uniquement visibles par les membres du forum ^^.
Dans la rubrique Liens & Références, vous avez accès à un sommaire de téléchargement, profitez-en !
Il existe maintenant un nouveau TOPIC "Votre CV en Ligne" accessible uniquement par demande.

#1 25-05-2012 15:44:54

infopower  
Membre Power Geek
Lieu: paris
Date d'inscription: 13-04-2011
Messages: 213
Pépites: 1,060
Banque: 0

Folder Monitor

Bonjour,
Avez-vous utilisé la fonction FindFirstChangeNotification qui permet de suivre les modifications sur répertoire.
En faite je cherchais sur net des trus qui permettent de l’utiliser comme Externel function dans power builder mais je n’ai rien trouvé


la vie est une course et il faut avoir un bon depart

Hors ligne

 

#2 25-05-2012 23:10:33

xlat  
0xc0000005
Award: bf
Lieu: Tanger (طنج)
Date d'inscription: 04-12-2010
Messages: 720
Pépites: 11,343
Banque: 100,221,387,868,884,300
Site web

Re: Folder Monitor

Bonjour,

il faut regarder du côté MSDN.

- FindFirstChangeNotification
- FindCloseChangeNotification
- WaitForSingleObject

sinon voici un petit exemple ; w_main.srw :

Code: pb

forward
global type w_main from window
end type
type st_adv from statictext within w_main
end type
type st_status from statictext within w_main
end type
type sle_dir from singlelineedit within w_main
end type
type cb_start from commandbutton within w_main
end type
type cb_close from commandbutton within w_main
end type
end forward

global type w_main from window
integer width = 1847
integer height = 1164
boolean titlebar = true
string title = "folder change"
boolean controlmenu = true
windowtype windowtype = response!
long backcolor = 67108864
string icon = "AppIcon!"
boolean center = true
st_adv st_adv
st_status st_status
sle_dir sle_dir
cb_start cb_start
cb_close cb_close
end type
global w_main w_main

type prototypes
function ulong FindFirstChangeNotification( string lpPathName,  boolean bWatchSubtree,  ulong dwNotifyFilter) library "kernel32.dll" alias for "FindFirstChangeNotificationW;unicode"
function boolean FindCloseChangeNotification( ulong handle ) library "kernel32.dll"
function Boolean FindNextChangeNotification( ulong hChangeHandle) library "kernel32.dll"
function ulong WaitForSingleObject(ulong hHandle,ulong dwMilliseconds) library "kernel32.dll"
end prototypes
type variables
ulong il_handle
end variables

on w_main.create
this.st_adv=create st_adv
this.st_status=create st_status
this.sle_dir=create sle_dir
this.cb_start=create cb_start
this.cb_close=create cb_close
this.Control[]={this.st_adv,&
this.st_status,&
this.sle_dir,&
this.cb_start,&
this.cb_close}
end on

on w_main.destroy
destroy(this.st_adv)
destroy(this.st_status)
destroy(this.sle_dir)
destroy(this.cb_start)
destroy(this.cb_close)
end on

event timer;if il_handle <>0 then
  ulong res
  res = WaitForSingleObject( il_handle, 1 )
  if 258 /*WAIT_TIMEOUT */ <> res then
    if res = 0 then
      st_adv.text += "dir changed - " + string(now(), "hh:mm:ss.ffffff" ) + "~r~n"
      FindNextChangeNotification( il_handle )
    end if    
  end if
end if
end event

event open;sle_dir.text = GetCurrentDirectory()
end event

type st_adv from statictext within w_main
integer x = 5
integer y = 480
integer width = 1815
integer height = 540
integer textsize = -10
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = ""
boolean border = true
borderstyle borderstyle = stylelowered!
boolean focusrectangle = false
end type

type st_status from statictext within w_main
integer x = 5
integer y = 256
integer width = 1819
integer height = 104
integer textsize = -10
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
long backcolor = 67108864
string text = "(status)"
boolean border = true
borderstyle borderstyle = stylelowered!
boolean focusrectangle = false
end type

type sle_dir from singlelineedit within w_main
integer x = 411
integer y = 124
integer width = 1399
integer height = 112
integer taborder = 30
integer textsize = -10
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
long textcolor = 33554432
string text = "c:\"
borderstyle borderstyle = stylelowered!
end type

type cb_start from commandbutton within w_main
integer y = 128
integer width = 402
integer height = 112
integer taborder = 20
integer textsize = -10
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "Start"
end type

event clicked;
il_handle = FindFirstChangeNotification( sle_dir.text, false, 31 /* FILE_NOTIFY_CHANGE_FILE_NAME .. FILE_NOTIFY_CHANGE_LAST_WRITE */ )
st_status.text = "handle = " + string( il_handle )

timer( 0.5 )
end event

type cb_close from commandbutton within w_main
integer width = 402
integer height = 112
integer taborder = 10
integer textsize = -10
integer weight = 400
fontcharset fontcharset = ansi!
fontpitch fontpitch = variable!
fontfamily fontfamily = swiss!
string facename = "Tahoma"
string text = "close"
boolean cancel = true
end type

event clicked;if il_handle <> 0 then
  FindCloseChangeNotification( il_handle )
  il_handle = 0
end if

Close( parent )
end event

Dernière modification par xlat (25-05-2012 23:13:28)


https://lut.im/eJINqa9o/vAtyxD0h "Don't believe everything you read on the Internet"
    -- Abraham Lincoln

www.ngs.ma

Hors ligne

 

Pied de page des forums

Propulsé par FluxBB 1.2.22