Nous utilisons des cookies pour vous garantir la meilleure expérience sur notre site. Si vous continuez à utiliser ce dernier, nous considèrerons que vous acceptez l'utilisation des cookies. J'ai compris ! ou En savoir plus !.
banniere

Le portail francophone de la géomatique


Toujours pas inscrit ? Mot de passe oublié ?
Nom d'utilisateur    Mot de passe              Toujours pas inscrit ?   Mot de passe oublié ?

Annonce

Rencontres QGIS 2025

L'appel à participation est ouvert jusqu'au 19 janvier 2025!

#1 Tue 11 September 2001 21:53

Sébastien RODDIER
Invité

chemin d'acces a un repertoire

Bonjour a tous

Je cherche a recuperer dans une variable STRING le chemins d'acces a un repertoire selectionne par l'utilisateur dans une boite de dialogue.

quelqu'un aurait t'il une idee?

a+

sebastien

 

#2 Wed 12 September 2001 21:53

Sébastien RODDIER
Invité

Re: chemin d'acces a un repertoire

Bonjour a tous

J'ai une solution trouvee sur le site de J.Paris que je vous invite a aller voir pour plus d'explications.

Voici le code, a vous de l'adpater selon vos besoins :
--------------------------------------------------------------
Declare Function FolderOrFilename
(ByVal hMIWinHandle as integer,  'MapInfo Window Handle
ByVal TypeBrowse as Integer,   '0 for Folder; >0 for File
ByVal Title as String)      'Title for the Dialog
as string            'Result is  if nothing chosen

'*************** Win 98 Shell Declarations ***************
Define BIF_RETURNONLYFSDIRS  &H0001
Define BIF_BROWSEINCLUDEFILES &H4000

Type TitleString
Title as String
End Type

Type BrowseInfo
hWndOwner As Integer
pIDLRoot As Integer
pszDisplayName As Integer
lpszTitle As TitleString
ulFlags As Integer
lpfnCallback As Integer
lParam As Integer
iImage As Integer
End Type

Declare Sub CoTaskMemFree Lib ole32.dll (ByVal hMem As Integer)

Declare Function SHBrowseForFolder Lib shell32
(lpbi As BrowseInfo) As Integer

Declare Function SHGetPathFromIDList Lib shell32
(ByVal pidList As Integer, lpBuffer As String) As Integer

'*************** FindFile Declarations ***************
Define MAX_PATH 260

Type FILETIME
dwLowDateTime As integer
dwHighDateTime As integer
End Type

Type WIN32_FIND_DATA
dwFileAttributes As integer
ftCreationTime As FILETIME
ftLastAccessTime As FILETIME
ftLastWriteTime As FILETIME
nFileSizeHigh As integer
nFileSizeLow As integer
dwReserved0 As integer
dwReserved1 As integer
cFileName As String * MAX_PATH
cAlternate As String * 14
End Type

Declare Function FindFirstFile Lib kernel32 Alias FindFirstFileA
(ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As integer

Declare Function FindClose Lib kernel32  Alias FindClose
(ByVal hFindFile As Integer) As Integer

Function FolderOrFilename
(ByVal hMIWinHandle as integer, ByVal TypeBrowse as Integer,
ByVal Title as String) as string

Dim lpIDList, lResult, hFF As Integer
Dim udtBI As BrowseInfo, f as WIN32_FIND_DATA, sPath as String
FolderOrFilename=

udtBI.hWndOwner = hMIWinHandle    'Set the owner window

if TypeBrowse=0 then         'Folders only or Folders & Files?
udtBI.ulFlags = BIF_RETURNONLYFSDIRS
else udtBI.ulFlags = BIF_BROWSEINCLUDEFILES End if

udtBI.lpszTitle.Title = Title

'Show the 'Browse for folder' dialog
lpIDList = SHBrowseForFolder(udtBI)

If lpIDList > 0 Then
sPath = Space(MAX_PATH)
'Get the path from the IDList
lResult = SHGetPathFromIDList(lpIDList, sPath)
If lResult=1 then
FolderOrFilename=sPath
' If looking for file, make sure it's not a folder
If TypeBrowse=1 then
hFF=FindFirstFile (sPath, f)
if (f.dwFileAttributes 16) mod 2 = 1 then FolderOrFilename=  End if
lResult=FindClose (hFF)
End if
End if
End If
Call CoTaskMemFree(lpIDList)
End Function

Define SYS_INFO_MAPINFOWND 9
Dim ResultName as string

ResultName=FolderOrFilename(SystemInfo(SYS_INFO_MAPINFOWND), 0, Select a Folder )

If ResultName =  then Note No Folder Chosen
Else Note Chosen Folder:  + ResultName End if

ResultName=FolderOrFilename(SystemInfo(SYS_INFO_MAPINFOWND),1, Select a File )

If ResultName =  "" then Note "No FileName Chosen"
Else Note "Chosen FileName:  "+ ResultName End if

a bientot

 

Pied de page des forums

Powered by FluxBB