Newsgroup: it.comp.lang.visual-basic
Titolo: [VB6]    GetShortPathName

hello
il codice qui in vb6 e' ok,ma se lo uso in VBA cpn poerpoint
l'API in oggetto non funziona...che cosa sbaglio ?
Dim cmdToDo As String
Dim dwreturn As Long
Dim ret As String * 128
Dim tmp As String * 255
Dim lenShort A s Long
Dim ShortPathAndfile As String
tmp = ""
'
lenShort = GetShortPathName(Filename, tmp, 255)
ShortPathAndfile = Left$(tmp, lenShort)
'
cmdToDo = "open " & ShortPathAndfile & " type MPEGVideo Alias mpeg"
dwreturn = mciSendString(cmdToDo, 0&, 0&, 0&)
If dwreturn <> 0 Then GoTo errore
'
dwreturn = mciSendString("status  mpeg length", ret, Len(ret), 0&)
'
errore:
If dwreturn <> 0 Then  'Print Not success
mciGetErrorString dwreturn, ret, 128
MsgBox ret, vbCritical
Exit Function
End If
'----------------------------
dwreturn = mciSendString("play mpeg", 0&, 0&, 0&)
'-------------------------------------
  If dwreturn <> 0 Then
       mciGetErrorString dwreturn, ret, 128
      MsgBox ret, vbCritical
      Exit Function
   End If
graie1000
leonello

 dwreturn = mciSendString(cmdToDo, 0&, 0&, 0&)
ma sei sicuro che si aspetti necessariamente un nome corto?
-- 
ciao, hal


hai ragione non e' necessario un short name.....e' stata una mia
"cantonata"
ti prego,se sai qualcosa su come bloccara (non rendere disponibile in una
applicazione,la tasiera.
vedi un mio post
grazie e ciao
leonello

 applicazione,la tasiera.
Come ti hanno detto dipende molto dal sistema operativo ..
tu hai detto su che sistemi vuoi usarlo ?
--
Fosco

"leonello"
Mi pare che tu abbia ciesto per l'hook :
prova a premere shift+S
'In un form
Private Sub Form_Load()
 hHook = SetWindowsHookEx(WH_KEYBOARD, AddressOf _
  KeyboardProc, App.hInstance, App.ThreadID)
End Sub
Private Sub Form_Unload(Cancel As Integer)
    UnhookWindowsHookEx hHook
End Sub
'In un modulo
Public Const WH_KEYBOARD = 2
Public Const VK_SHIFT = &H10
Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, _
ByVal ncode As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) _
As Integer
Declare Function SetWindowsHookEx Lib "user32" Alias _
"SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, _
ByVal hmod As Long, ByVal dwThreadId As Long) As Long
Declare Function UnhookWindowsHookEx Lib "user32" _
 (ByVal hHook As Long) As Long
Public hHook As Long
Public Function KeyboardProc(ByVal idHook As Long, ByVal _
wParam As Long, ByVal lParam As Long) As Long
'if idHook is less than zero, no further processing is required
    If idHook < 0 Then
        'call the next hook
KeyboardProc = CallNextHookEx(hHook, idHook, wParam, _
ByVal lParam)
    Else
        'check if SHIFT-S is pressed
If (GetKeyState(VK_SHIFT) And &HF0000000) And wParam _
= Asc("S") Then
            'show the result
            Form1.Print "Shift-S pressed ..."
        End If
        'call the next hook
KeyboardProc = CallNextHookEx(hHook, idHook, _
wParam, ByVal lParam)
    End If
End Function
--
Fosco

"leonello"
altro esempio che funziona su un win9x :
' se cerchi (anche su google) trovi esempi e combinazioni
' piu complete
'form
Private Sub Command1_Click()
Call DisattivaTasti
End Sub
Private Sub Command2_Click()
Call AttivaTasti
End Sub
Private Sub Command3_Click()
Call NascondiTaskBar
End Sub
Private Sub Command4_Click()
Call MostraTaskBar
End Sub
Private Sub Form_Load()
End Sub
' modulo
Public Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal
uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As Long
Public Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As
String) As Long
Public Const SS = 97
Public Const SW_HIDE = 0
Public Const SW_SHOW = 5
Public Sub AttivaTasti()
'Attiva le combinazioni di tasti "CTRL+ALT+CANC", "CTRL+ESC", "ALT+TAB"
   Dim r As Integer
   Dim p As Boolean
   r = SystemParametersInfo(SS, False, p, 0)
End Sub
Public Sub DisattivaTasti()
'Disattiva le combinazioni di tasti "CTRL+ALT+CANC", "CTRL+ESC", "ALT+TAB"
   Dim r As Integer
   Dim p As Boolean
   r = SystemParametersInfo(SS, True, p, 0)
End Sub
Public Sub NascondiTaskBar()
   Dim g_hwndTray As Long
   g_hwndTray = FindWindow("Shell_TrayWnd", vbNullString)
   ShowWindow g_hwndTray, SW_HIDE
End Sub
Public Sub MostraTaskBar()
   Dim g_hwndTray As Long
   g_hwndTray = FindWindow("Shell_TrayWnd", vbNullString)
   ShowWindow g_hwndTray, SW_SHOW
End Sub
Public Sub BloccaUtente()
   DisattivaTasti
   NascondiTaskBar
End Sub
Public Sub SbloccaUtente()
   AttivaTasti
   MostraTaskBar
End Sub
--
Fosco