초기 화면입니다.
URL 입력 텍스트 박스에 URL을 입력하고 만들고 싶은 폴더를 선택하면 인터넷 바로가기인 *.url 파일이 생성된다.
아래 이미지 바탕화면에 인터넷 바로가기 파일을 생성한 이미지다
소스는 아래와 같다
' 인터넷 바로가기인 url 파일 만들기
Option Explicit
Private Const CSIDL_FAVORITES = &H6 '즐겨찾기
Private Const CSIDL_STARTMENU = &HB '시작메뉴
Private Const CSIDL_DESKTOPDIRECTORY = &H10 '바탕화면
Private Const S_OK = 0 ' 성공
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal PIDL As Long, ByVal pszPath As String) As Long
Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, PIDL As Long) As Long
Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal pv As Long)
Private Enum CSIDLSelectNumber
CSIDLSN_DeskTop = 0 ' 바탕화면
CSIDLSN_Favorite ' 즐겨찾기
CSIDLSN_StartMenu ' 시작메뉴
CSIDLSN_QuiceMenu ' 빠른실행
End Enum
Private Sub cmdPosition_Click(Index As Integer)
Dim SaveFolder As String ' 인터넷 바로가기 파일을 생성할 폴더
Dim fso As Scripting.FileSystemObject
Dim URLFile As Scripting.TextStream
Select Case Index
Case CSIDLSN_QuiceMenu
SaveFolder = Environ("homedrive") & Environ("homepath") & "\" & "Application Data\Microsoft\Internet Explorer\Quick Launch"
Case Else
SaveFolder = GetSpecialPath(Switch(Index = CSIDLSN_DeskTop, CSIDL_DESKTOPDIRECTORY, Index = CSIDLSN_Favorite, CSIDL_FAVORITES, Index = CSIDLSN_StartMenu, CSIDL_STARTMENU))
End Select
Debug.Print SaveFolder
SaveFolder = SaveFolder & "\"
Set fso = New Scripting.FileSystemObject
Set URLFile = fso.CreateTextFile(SaveFolder & "Test.URL", True)
With URLFile
.WriteLine ("[InternetShortcut]")
.WriteLine ("URL=" & txtURL.Text)
.Close
End With
MsgBox "인터넷 바로가기를 생성했읍니다."
End Sub
Private Function GetSpecialPath(CSIDL As Long) As String ' 지정된 경로를 얻는다
Dim RValue As Long ' 반환값
Dim PIDL As Long ' 경로
Dim Path As String ' 버퍼
GetSpecialPath = vbNullString
If SHGetSpecialFolderLocation(0, CSIDL, PIDL) = S_OK Then
Path = Space$(512)
RValue = SHGetPathFromIDList(PIDL, ByVal Path)
GetSpecialPath = Left$(Path, InStr(Path, vbNullChar) - 1)
CoTaskMemFree PIDL
End If
End Function
인터넷 바로가기 파일(*.url)의 형식은 다음 링크를 참조하세요 : 인터넷 바로가기인 URL 파일의 형식
'API' 카테고리의 다른 글
레지스트리 값 생성,읽기,쓰기,삭제 (0) | 2011.09.11 |
---|---|
GetWindowThreadProcessId 사용한 지정된 윈도우에 해당하는 프로세스 강제 종료시키기 (0) | 2011.09.10 |
WM_PASTE 메세지, 클립보드를 사용한 복사 (0) | 2011.09.09 |
InternetReadFile을 이용한 HTTP,FTP의 URL 응답 메시지 읽어오기 (0) | 2011.09.08 |
InternetOpenUrl을 사용한 FTP에서의 파일,디렉토리 존재 유무 확인 (0) | 2011.09.08 |