473,597 Members | 2,342 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help declaring PathCleanupspec

Hey folks,
I'm trying to use the PathCleanupSpec function from the shell library.

The function prototype is:
int PathCleanupSpec ( LPCWSTR pszDir, LPWSTR pszSpec)

In the old days of VB6, I would make the parameters Longs, and use the
StrPtr function.
Begin new to Dot Net, I can't figure out how to make this beast work.

Can someone tell me how to prototype the Declare function for this?

Thanks in advance,
-Buddy Robbins
Nov 21 '05 #1
3 1774
Hi

I am not sure if I have this correct, but here is what I think:

Imports:

Imports System.Runtime. InteropServices ' For DLLImport
Imports System.Text ' For StringBuilder

Constants:

Public Const PCS_REPLACEDCHA RS As Integer = &H1
Public Const PCS_REMOVEDCHAR S As Integer = &H2
Public Const PCS_SHORTENED As Integer = &H4
Public Const PCS_PATHTOOLONG As Integer = &H8
Public Const PCS_FATAL As Integer = &H8000000

Function:

Public Declare Unicode Function PathCleanupSpec Lib "Shell32.dl l" _
(ByVal pszDir As StringBuilder, _
<MarshalAs(Unma nagedType.LPWSt r)> _
ByVal pszSpec As String) As Integer

or

<DllImport("she ll32.dll", CallingConventi on:=CallingConv ention.StdCall, _
CharSet:=CharSe t.Unicode, entrypoint:="Pa thCleanUpSpecAW ")> _
Public Shared Function PathCleanupSpec _
(ByVal pszDir As StringBuilder, _
<MarshalAs(Unma nagedType.LPWSt r)> _
ByVal pszSpec As StringBuilder) As Integer
End Function

-----------------------------------------------------------------------------------------

Ok, looking in the Platform SDK (Feb 2003) at the function you asked about
it mentions that the strings need to be NULL terminated Unicode strings.

An LPCWSTR according to the .NET Framework SDK needs to be declared as
System.Text.Str ingBuilder, but can be declared as a string

The LPWStr is a NULL terminated 2-byte unicode string

The constants are declared in shlObj.h. All of them seem to be ok as an
integer, but if you declare the PCS_FATAL as a decimal then the number is out
of an integer scope. So, maybe you'll need to declare them as Int32.

I haven't tested the above because I have no use for it, but please let me
know the correct solution, if the above information is incorrect.

I hope this helps

"Buddy Robbins" wrote:
Hey folks,
I'm trying to use the PathCleanupSpec function from the shell library.

The function prototype is:
int PathCleanupSpec ( LPCWSTR pszDir, LPWSTR pszSpec)

In the old days of VB6, I would make the parameters Longs, and use the
StrPtr function.
Begin new to Dot Net, I can't figure out how to make this beast work.

Can someone tell me how to prototype the Declare function for this?

Thanks in advance,
-Buddy Robbins

Nov 21 '05 #2
Thanks for the assist, 'Crouchie'

In general, if there is an operating system function that performs a task, I
would use it before writing my own. In this case, we are really watching
our pennies on this project, so I was allowed to spend 15 minutes this
morning to get this to work. Well, I couldn't get the solution to run in
the time allotted, so I had to write my own routine (granted it was a
simple routine, but it's the principle).

Thanks for the assist, and I'll try to get it working on my own time.

-Buddy Robbins

"Crouchie19 98" <Cr**********@d iscussions.micr osoft.com> wrote in message
news:DD******** *************** ***********@mic rosoft.com...
Hi

I am not sure if I have this correct, but here is what I think:

Imports:

Imports System.Runtime. InteropServices ' For DLLImport
Imports System.Text ' For StringBuilder

Constants:

Public Const PCS_REPLACEDCHA RS As Integer = &H1
Public Const PCS_REMOVEDCHAR S As Integer = &H2
Public Const PCS_SHORTENED As Integer = &H4
Public Const PCS_PATHTOOLONG As Integer = &H8
Public Const PCS_FATAL As Integer = &H8000000

Function:

Public Declare Unicode Function PathCleanupSpec Lib "Shell32.dl l" _
(ByVal pszDir As StringBuilder, _
<MarshalAs(Unma nagedType.LPWSt r)> _
ByVal pszSpec As String) As Integer

or

<DllImport("she ll32.dll", CallingConventi on:=CallingConv ention.StdCall,
_
CharSet:=CharSe t.Unicode, entrypoint:="Pa thCleanUpSpecAW ")> _
Public Shared Function PathCleanupSpec _
(ByVal pszDir As StringBuilder, _
<MarshalAs(Unma nagedType.LPWSt r)> _
ByVal pszSpec As StringBuilder) As Integer
End Function

-----------------------------------------------------------------------------------------

Ok, looking in the Platform SDK (Feb 2003) at the function you asked about
it mentions that the strings need to be NULL terminated Unicode strings.

An LPCWSTR according to the .NET Framework SDK needs to be declared as
System.Text.Str ingBuilder, but can be declared as a string

The LPWStr is a NULL terminated 2-byte unicode string

The constants are declared in shlObj.h. All of them seem to be ok as an
integer, but if you declare the PCS_FATAL as a decimal then the number is
out
of an integer scope. So, maybe you'll need to declare them as Int32.

I haven't tested the above because I have no use for it, but please let me
know the correct solution, if the above information is incorrect.

I hope this helps

"Buddy Robbins" wrote:
Hey folks,
I'm trying to use the PathCleanupSpec function from the shell library.

The function prototype is:
int PathCleanupSpec ( LPCWSTR pszDir, LPWSTR pszSpec)

In the old days of VB6, I would make the parameters Longs, and use the
StrPtr function.
Begin new to Dot Net, I can't figure out how to make this beast work.

Can someone tell me how to prototype the Declare function for this?

Thanks in advance,
-Buddy Robbins

Nov 21 '05 #3
Tell me exactly what you want & I will try & code it for you. I will have
time later to spend a few hours if you need

"Buddy Robbins" wrote:
Thanks for the assist, 'Crouchie'

In general, if there is an operating system function that performs a task, I
would use it before writing my own. In this case, we are really watching
our pennies on this project, so I was allowed to spend 15 minutes this
morning to get this to work. Well, I couldn't get the solution to run in
the time allotted, so I had to write my own routine (granted it was a
simple routine, but it's the principle).

Thanks for the assist, and I'll try to get it working on my own time.

-Buddy Robbins

"Crouchie19 98" <Cr**********@d iscussions.micr osoft.com> wrote in message
news:DD******** *************** ***********@mic rosoft.com...
Hi

I am not sure if I have this correct, but here is what I think:

Imports:

Imports System.Runtime. InteropServices ' For DLLImport
Imports System.Text ' For StringBuilder

Constants:

Public Const PCS_REPLACEDCHA RS As Integer = &H1
Public Const PCS_REMOVEDCHAR S As Integer = &H2
Public Const PCS_SHORTENED As Integer = &H4
Public Const PCS_PATHTOOLONG As Integer = &H8
Public Const PCS_FATAL As Integer = &H8000000

Function:

Public Declare Unicode Function PathCleanupSpec Lib "Shell32.dl l" _
(ByVal pszDir As StringBuilder, _
<MarshalAs(Unma nagedType.LPWSt r)> _
ByVal pszSpec As String) As Integer

or

<DllImport("she ll32.dll", CallingConventi on:=CallingConv ention.StdCall,
_
CharSet:=CharSe t.Unicode, entrypoint:="Pa thCleanUpSpecAW ")> _
Public Shared Function PathCleanupSpec _
(ByVal pszDir As StringBuilder, _
<MarshalAs(Unma nagedType.LPWSt r)> _
ByVal pszSpec As StringBuilder) As Integer
End Function

-----------------------------------------------------------------------------------------

Ok, looking in the Platform SDK (Feb 2003) at the function you asked about
it mentions that the strings need to be NULL terminated Unicode strings.

An LPCWSTR according to the .NET Framework SDK needs to be declared as
System.Text.Str ingBuilder, but can be declared as a string

The LPWStr is a NULL terminated 2-byte unicode string

The constants are declared in shlObj.h. All of them seem to be ok as an
integer, but if you declare the PCS_FATAL as a decimal then the number is
out
of an integer scope. So, maybe you'll need to declare them as Int32.

I haven't tested the above because I have no use for it, but please let me
know the correct solution, if the above information is incorrect.

I hope this helps

"Buddy Robbins" wrote:
Hey folks,
I'm trying to use the PathCleanupSpec function from the shell library.

The function prototype is:
int PathCleanupSpec ( LPCWSTR pszDir, LPWSTR pszSpec)

In the old days of VB6, I would make the parameters Longs, and use the
StrPtr function.
Begin new to Dot Net, I can't figure out how to make this beast work.

Can someone tell me how to prototype the Declare function for this?

Thanks in advance,
-Buddy Robbins


Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2329
by: Tim | last post by:
Can someone please post a code example demonstrating the use of the shell32.dll PathCleanupSpec() function? Thanks in advance!
39
2572
by: Steven T. Hatton | last post by:
I came across this while looking for information on C++ and CORBA: http://www.zeroc.com/ice.html. It got me to wondering why I need two different languages in order to write distributed computing apps. In the case of CORBA, that means IDL and C++. In the case of ICE, that means slice and C++. Slice actually looks a lot closer to C++ than does IDL. Nonetheless, I'm wondering if there is some fundamental limitation in C++ which precludes...
5
2223
by: param | last post by:
Declaring struct as static is creating problem with newer version of CC compiler 5.7 in solaris. e.g. static struct new_str { int a; int b; };
27
1959
by: sam_cit | last post by:
Hi, I needed help in converting a character to the correspoding hexadecimal values, like the following example, ASCII value : ABC Hex Code Value : %41%42%43... whats the logic of conversion...
32
3029
by: lcdgoncalves | last post by:
Hi everyone Is there a real need to use keyword static with functions, if we simply don't declare their prototypes in .h file? Many textbooks avoid to discuss this matter and/or discuss only the usage of static functions. I've been programming for years and I never felt a real need for the "static approach for functions". I don't know if this is a trivial matter since the reserved word
8
7502
by: SM | last post by:
I've always wonder if there is diference when declaring and initializing a varible inside/outside a loop. What's a better practice? Declaring and initializing variables inside a loop routine, like this: for(var i=0; i<list; i++) { var name = list; }
8
2927
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using vs2005, .net 2, C# for Windows application. I use DllImport so I can call up a function written in C++ as unmanaged code and compiled as a dll us vs2005. My application is able to call the function, EncodeAsnUser. And it's returning OK but when I display the decoded data in another part of my application it shows no data has been decoded, all fiedls are either null or blanks. For some reason, I am not able to step through...
11
1385
by: AAaron123 | last post by:
newItem and tsMenuItem are ToolStripMenuItems. I'd like to add the click event in tsMenuItem to newItem. Can't do this because Events is Protected: newItem.Events.AddHandlers(tsMenuItem.Events);
8
4576
by: nguillot | last post by:
Hello. If I have the following classes: class B {}; typedef B tB; if A is: class A
0
8272
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8381
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8035
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8258
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6688
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
3886
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3927
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1494
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1238
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.