Re: How do I get the source path of clipboard?



Thank you , every one, for replying.
I can do it by getting the LINK data from the clipboard.
The code is as follows.

'-----------------------------------------------------------
Private Declare Function OpenClipboard Lib "User32" _
(ByVal hwnd As Long) As Long
Private Declare Function CloseClipboard Lib "User32" _
() As Long
Private Declare Function GetClipBoardData Lib "User32" _
Alias "GetClipboardData" _
(ByVal wFormat As Long) As Long

Private Declare Function GlobalAlloc Lib "kernel32" _
(ByVal wFlags&, ByVal dwBytes As Long) As Long
Private Declare Function GlobalLock Lib "kernel32" _
(ByVal hMem As Long) As Long
Private Declare Function GlobalUnlock Lib "kernel32" _
(ByVal hMem As Long) As Long
Private Declare Function GlobalSize Lib "kernel32" _
(ByVal hMem As Long) As Long

Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
(Destination As Any, ByVal Source As Long, ByVal Length As Long)


Sub Main()
Const lLink As Long = &HC1F5&
Dim lResult As Long
Dim hHandle As Long
Dim lClipAddr As Long
Dim bData() As Byte
Dim lSize As Long
Dim sSourcePathInfo As String
sSourcePathInfo = "No Link Information in the clipboard."

lResult = OpenClipboard(Application.hwnd)
If lResult Then
hHandle = GetClipBoardData(lLink)
If hHandle Then
lClipAddr = GlobalLock(hHandle)
lSize = GlobalSize(hHandle)
ReDim bData(0 To lSize - 1)
CopyMemory bData(0), lClipAddr, lSize
sSourcePathInfo = StrConv(bData, vbUnicode)
GlobalUnlock (lClipAddr)
End If
End If
CloseClipboard
Debug.Print sSourcePathInfo
End Sub


"Larry Serflaten" <serflaten@xxxxxxxxxxxxxx> wrote in message
news:Ou$GpRwgGHA.4892@xxxxxxxxxxxxxxxxxxxxxxx

"Zoo" <ayamashi@xxxxxxxxxxx> wrote
I am trying to get the source path of clipboard.
eg.
1) Open "C:\temp\test.xls" for example.
2) Select "A1:B2" and copy that.
3) From my VB6 Application , I want to know the source path.

How about refering back to step 1?

Another interesting question might be:

What documentation do you have that indicates the
source path would be stored on the clipboard? You
can't get what isn't there....

LFS



.