Declare a fixed-length string

T

Tim Munro

Hi all,
I need to delcare a fixed length string for use in the
"GetPrivateProfileString" function. I can't figure out how to do this in
VB.NET (2008).

Thanks.
 
T

Tom Shelton

Hi all,
I need to delcare a fixed length string for use in the
"GetPrivateProfileString" function. I can't figure out how to do this in
VB.NET (2008).

Thanks.
 
C

Cor Ligthert[MVP]

Tim,

There does not exist a fixed length string in MS development.

The only thing you can do is fix the length that you get or set.

Cor
 
T

Tim Munro

Thanks everyone for your suggestions. I am certainly not married to the INI
format. This poses the following question then: If I have a group of people
all using the same program (like a Service Desk) how would you recommend
setting up the initialization for that program? If in the registry, and I
need to make a change then everyone has to update their registry? The seems
like a loss of funtionality to me. Is there a better way to do program
initialization?

Any help/advice would be greatly appreciated.
 
O

Onur Güzel

Thanks everyone for your suggestions. I am certainly not married to the INI
format. This poses the following question then: If I have a group of people
all using the same program (like a Service Desk) how would you recommend
setting up the initialization for that program? If in the registry, and I
need to make a change then everyone has to update their registry? The seems
like a loss of funtionality to me. Is there a better way to do program
initialization?

Any help/advice would be greatly appreciated.

--
Tim






- Show quoted text -

Hi,
Look at P/Invoke for GetPrivateProfileString API:
http://www.pinvoke.net/default.aspx/kernel32.GetPrivateProfileString

In that article, it uses StringBuilder and nSize parameter is passed
as StringBuilder's capacity. Beyond this you may want to check out
that MSDN page for additional description of that API:
http://msdn.microsoft.com/en-us/library/ms724353(VS.85).aspx

Hope this helps,

Onur Güzel
 
T

Tim Munro

Thanks Onur, I'll take a look at that.
--
Tim

Thanks everyone for your suggestions. I am certainly not married to the
INI
format. This poses the following question then: If I have a group of
people
all using the same program (like a Service Desk) how would you recommend
setting up the initialization for that program? If in the registry, and I
need to make a change then everyone has to update their registry? The
seems
like a loss of funtionality to me. Is there a better way to do program
initialization?

Any help/advice would be greatly appreciated.

--
Tim

message




- Show quoted text -

Hi,
Look at P/Invoke for GetPrivateProfileString API:
http://www.pinvoke.net/default.aspx/kernel32.GetPrivateProfileString

In that article, it uses StringBuilder and nSize parameter is passed
as StringBuilder's capacity. Beyond this you may want to check out
that MSDN page for additional description of that API:
http://msdn.microsoft.com/en-us/library/ms724353(VS.85).aspx

Hope this helps,

Onur Güzel
 
T

Tim Munro

That's the cleanest solution I've come across so far. Thanks very much.

--
Tim

Thanks everyone for your suggestions. I am certainly not married to the
INI
format. This poses the following question then: If I have a group of
people
all using the same program (like a Service Desk) how would you recommend
setting up the initialization for that program? If in the registry, and I
need to make a change then everyone has to update their registry? The
seems
like a loss of funtionality to me. Is there a better way to do program
initialization?

Any help/advice would be greatly appreciated.

--
Tim

message




- Show quoted text -

Hi,
Look at P/Invoke for GetPrivateProfileString API:
http://www.pinvoke.net/default.aspx/kernel32.GetPrivateProfileString

In that article, it uses StringBuilder and nSize parameter is passed
as StringBuilder's capacity. Beyond this you may want to check out
that MSDN page for additional description of that API:
http://msdn.microsoft.com/en-us/library/ms724353(VS.85).aspx

Hope this helps,

Onur Güzel
 
H

Harry

Tim Munro said:
Hi all,
I need to delcare a fixed length string for use in the
"GetPrivateProfileString" function. I can't figure out how to do this in
VB.NET (2008).

Thanks.

What about something simple like?:

Dim mystring As New String(" "c, 12) - creates a space filled string of 12
characters
 
H

Herfried K. Wagner [MVP]

Michael D. Ober said:
For API functions that expect a string to fill in, use the StringBuilder
class.

Or simply 'As String' if the 'Declare' statement is used. The marshalling
will be done automatically then, maybe with a little loss in performance.
 
T

Tim Munro

Ooo I like that even better. What I have been using is:

Dim lpReturnedString as VB6.FixedLengthString(255)

I'm trying to remove any VB6 compatibility requirements. (This is an
upgraded project from VB6 to VB.NET 2008)

Ultimately the question remains: Is there a better way to do program
initialization that does not require updating everyones workstation if a
parameter changes?

Thanks very much.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top