westconn, thanks a lot. ya, i miss to change that line of code. now i think the program is work smooth already. then i plan to made a command button so can direct access the myPic folder from vb. below is my code
which is study from my post previously in this thread http://www.vbforums.com/showthread.php?t=550827 However, when i execute it, error variable not found and highlighted on cnt = cnt + 1. what wrong and how to correct it?Code:Option Explicit Private Const CSIDL_DESKTOP = &H0 Private Const NOERROR = 0 Private Type SHTEMID cb As Long abID As Byte End Type Private Type ITEMIDLIST mkid As SHTEMID End Type Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long Private Const SW_HIDE As Long = 0 Private Const SW_SHOWNORMAL As Long = 1 Private Const SW_SHOWMAXIMIZED As Long = 3 Private Const SW_SHOWMINIMIZED As Long = 2 Dim strDesktop As String Private Sub Command2_Click() strDesktop = GetSpecialfolder(CSIDL_DESKTOP) ShellExecute Me.hwnd, "open", strDesktop & "\webcam\myPic", vbNullString, strDesktop & "\webcam\myPic", SW_SHOWNORMAL End Sub Private Sub Form_Load() Debug.Print "Desktop path: " & GetSpecialfolder(CSIDL_DESKTOP) End Sub Private Function GetSpecialfolder(CSIDL As Long) As String Dim r As Long Dim IDL As ITEMIDLIST Dim Path$ 'Get the special folder r = SHGetSpecialFolderLocation(100, CSIDL, IDL) If r = NOERROR Then 'Create a buffer Path$ = Space$(512) 'Get the path from the IDList r = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal Path$) 'Remove the unnecessary chr$(0)'s GetSpecialfolder = Left$(Path, InStr(Path, Chr$(0)) - 1) Exit Function End If GetSpecialfolder = "" End Function




Reply With Quote