why isn't this api working? 
Author Message
 why isn't this api working?

'declaration

Private Declare Function PathCompactPath _
        Lib "shlwapi" Alias "PathCompactPathA" ( _
        ByVal hDC As IntPtr, _
        ByVal lpszPath As String, _
        ByVal dx As Integer) As Integer

'code
Dim strFilePath As String = "C:\Program Files\Some
Company\Some Product\File.txt"

PathCompactPath(Me.Handle, strFilePath, 250)

Dim strNewPath as String = strFilePath

No matter what i change the size to (250), it only returns
the file name ("...\File.txt").

thanks,
todd



Sat, 24 Sep 2005 23:30:17 GMT  
 why isn't this api working?
Hello,


Quote:
> Private Declare Function PathCompactPath _
>         Lib "shlwapi" Alias "PathCompactPathA" ( _
> ByVal hDC As IntPtr, _
> ByVal lpszPath As String, _
> ByVal dx As Integer) As Integer

> 'code
> Dim strFilePath As String = "C:\Program Files\Some
> Company\Some Product\File.txt"

> PathCompactPath(Me.Handle, strFilePath, 250)

> Dim strNewPath as String = strFilePath

> No matter what i change the size to (250), it only returns
> the file name ("...\File.txt").

You give PathCompactPath a Window Handle where a handle to a DC is expected.
This doesn't work.

Try the code below:

\\\
Private Declare Function GetWindowDC Lib "user32.dll" ( _
    ByVal hwnd As IntPtr _
) As IntPtr

Private Declare Function ReleaseDC Lib "user32.dll" ( _
    ByVal hwnd As IntPtr, _
    ByVal hdc As IntPtr _
) As IntPtr

Private Declare Function PathCompactPath Lib "shlwapi.dll" Alias
"PathCompactPathA" ( _
    ByVal hDC As IntPtr, _
    ByVal lpszPath As String, _
    ByVal dx As Int32 _
) As Integer

Private Sub Test()
    Dim hDC As IntPtr = GetWindowDC(Me.Handle)
    Dim strFilePath As String = _
        "C:\Program Files\Some Company\Some Product\bla\bla\File.txt"
    PathCompactPath(hDC, strFilePath, 250)
    MsgBox(strFilePath)
    ReleaseDC(Me.Handle, hDC)
End Sub
///

Regards,
Herfried K. Wagner



Wed, 28 Sep 2005 19:44:10 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. why isn't this api code working?

2. Why isn't any API code working

3. Why isn't my code working?

4. Why isn't my filter working in the Common Dialog ShowOpen Function

5. Why Isn't MyBase.New() Working Here?

6. Why isn't this working??

7. Why isn't this working?

8. why isn't this working?

9. Why isn't this working

10. Why isn't this working?

11. Why isn't this working?

12. why isn't this working

 

 
Powered by phpBB® Forum Software