Ciao #F ,
Vengo da questa guida e non leggendo inglese anche col traduttore sono in difficoltà.
Questo codice è utile da prendere in esempio? O serve per riconoscere Win? Io vorrei che la condizione sia tramite riconoscimento della versione di Excel.
#If Win64 Then
Private Declare PtrSafe Function Lib "shell32.dll" Alias _
"SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
#Else
Private Declare Function SHFileOperation Lib "shell32.dll" Alias _
"SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
#End If
\\
Oppure la soluzione è modificare PTRSAFE con LONGPTR ? No provato non funziona!
///
Sto cercando in internet ma non trovo nulla!
Vedo che, forse nella luce della mia risposta, hai modificato la tua domanda originale e ha aumentato sostanzialmente il suo ambito!
Comunque, il suggerimento offerto da me funzione senza alcun problema per me. Io l'ho provato così:
'=========>>
Option Explicit
Public Declare Function sndPlaySound32 _
Lib "winmm.dll" _
Alias "sndPlaySoundA" ( _
ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long
'--------->>
Public Sub Tester()
sndPlaySound32 "C:\Windows\Media\Chimes.wav", 0&
sndPlaySound32 "C:\Program Files\OpenOffice 4" _
& "share\gallery\sounds\Applause.wav", 0&
End Sub
'<<=========
Per utilizzare questa funzione API sia nell'ambiente 32 bit che 64 bit, il mio codice di prova diventerebbe:
'=========>>
Option Explicit
#If Win64 Then
Public Declare PtrSafe Function sndPlaySound32 _
Lib "winmm.dll" _
Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long
#Else
Public Declare Function sndPlaySound32 _
Lib "winmm.dll" _
Alias "sndPlaySoundA" _
(ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long
#End If
'--------->>
Public Sub Tester()
sndPlaySound32 "C:\Windows\Media\Chimes.wav", 0&
sndPlaySound32 "C:\Program Files\OpenOffice 4" _
& "share\gallery\sounds\Applause.wav", 0&
End Sub
'<<=========
Per urtilizzare la funzione API SHFileOperation Lib sia con VB6 (Excel 2007 e versioni precedenti) o VB7 (Excel 2010 +), prrova una dichiarazione con la compilazione condizionale del seguente genere:
'=========>>
Option Explicit
#If VBA7 Then
Type SHFILEOPSTRUCT
hWnd As Longptr
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAborted As Boolean
hNameMaps As Longptr
sProgress As String
End Type
Declare PtrSafe Function SHFileOperation _
Lib "shell32.dll" _
Alias "SHFileOperationA" _
(lpFileOp As SHFILEOPSTRUCT) As LongPtr
#Else
Type SHFILEOPSTRUCT
hWnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAborted As Boolean
hNameMaps As Long
sProgress As String
End Type
Declare Function SHFileOperation _
Lib "shell32.dll" _
Alias "SHFileOperationA" _
(lpFileOp As SHFILEOPSTRUCT) As Long
#End If
'<<=========
===
Regards,
Norman
