473,405 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Structure to Api call

The following code is converted from VB6 to VS2005.
The call to GetLocaleInfoLS returns always 0.
Please HELP !!!!

<StructLayout(LayoutKind.Sequential)> _
Private Structure LOCALESIGNATURE
<VBFixedArray(3)> Dim lsUsb() As Integer
<VBFixedArray(1)> Dim lsCsbDefault() As Integer
<VBFixedArray(1)> Dim lsCsbSupported() As Integer
Public Sub Initialize()
ReDim lsUsb(3)
ReDim lsCsbDefault(1)
ReDim lsCsbSupported(1)
End Sub
End Structure
<StructLayout(LayoutKind.Sequential)> _
Private Structure CHARSETINFO
Dim ciCharset As Integer
Dim ciACP As Integer
Dim Fs As FONTSIGNATURE
Public Sub Initialize()
Fs = New FONTSIGNATURE
Fs.Initialize()
End Sub
End Structure

Private Const LOCALE_FONTSIGNATURE As Integer = &H58 ' font signature
Private Const TCI_SRCFONTSIG As Short = 3

Private Class Api

Declare Auto Function GetLocaleInfoLS Lib "kernel32" Alias
"GetLocaleInfoA" ( _
ByVal Locale As Integer, _
ByVal LCType As Integer, _
ByRef lpLCData As LOCALESIGNATURE, _
ByVal cchData As Integer) As Integer

Declare Auto Function TranslateCharsetInfo Lib "GDI32" ( _
ByRef lpSrc As Integer, _
ByRef lpcs As CHARSETINFO, _
ByVal dwFlags As Integer) As Integer
End Class
Private Function GetUserCharset() As Short
Dim ls As New LOCALESIGNATURE() ' local signature struct.
ls.Initialize()
Dim ci As New CHARSETINFO() ' character set info struct.
ci.Initialize()
Dim RC As Integer
Dim lsl As Integer = Marshal.SizeOf(ls)

' get locale signature based on the USER's Default LCID.
'
' what is wrong with this call ?????
'
RC =
Api.GetLocaleInfoLS(System.Globalization.CultureIn fo.CurrentCulture.LCID, _
LOCALE_FONTSIGNATURE, ls, lsl)
If (RC > 0) Then ' if success
ls.lsCsbDefault(1) = 0 ' zero out bits
' translate charset info from locale fontsignature.
RC = Api.TranslateCharsetInfo(ls.lsCsbDefault(0), ci,
TCI_SRCFONTSIG)
If RC <> 0 Then GetUserCharset = ci.ciCharset ' return charset
End If
End Function

Nov 21 '05 #1
2 1666
"Simos_V" <Si****@discussions.microsoft.com> wrote in message
news:67**********************************@microsof t.com...
The following code is converted from VB6 to VS2005.
The call to GetLocaleInfoLS returns always 0.
Please HELP !!!!

<StructLayout(LayoutKind.Sequential)> _
Private Structure LOCALESIGNATURE


....

In general you shoudn't try to use the API signatures the upgrade wizard
creates.
When upgrading VB6 API calls to .NET, first look to find equivilent
functionality in the .NET framework.
99% of the time you can just rip out the API declare and use the .NET
framework.

From
http://msdn.microsoft.com/library/de...l/win32map.asp
GetLocaleInfo - Retrieves information about a locale.

Use
System.Globalization.CultureInfo.DateTimeFormat
System.Globalization.CultureInfo.NumberFormat
System.Globalization.CultureInfo.TextInfo
If that fails, look at www.pinvoke.net and find a tested API interop
signature.

If that fails, then you have to figure out the marshaling yourself.

David
Nov 21 '05 #2
Thank's David
In the future i will replace all Api calls with the .NET framework.
But i would prefer to have a runing project now before i will study and get
used to .NET framework
Nov 21 '05 #3

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

Similar topics

11
by: Mannequin* | last post by:
Hi all, I'm working on a quick program to bring the Bible into memory from a text file. Anyway, I have three questions to ask. First, is my implementation of malloc () correct in the program to...
2
by: Steve Turner | last post by:
I have read several interesting posts on passing structures to C dlls, but none seem to cover the following case. The structure (as seen in C) is as follows: typedef struct tag_scanparm { short...
4
by: Scott Lemen | last post by:
Hi, Some Win APIs expect a structure with a fixed length string. How is it defined in VB .Net 2003? When I try to use the FixedLengthString class I get an "Array bounds cannot appear in type...
15
by: Charles Law | last post by:
I have adapted the following code from the MSDN help for PropertyInfo SetValue. In the original code, the structure MyStructure is defined as a class MyProperty, and it works as expected. There is...
10
by: David Fort | last post by:
Hi, I'm upgrading a VB6 app to VB.net and I'm having a problem with a call to a function provided in a DLL. The function takes the address of a structure which it will fill in with values. I...
1
by: Falko Wagner | last post by:
Hi there, I am currently translating a VB 6.0 application to .NET and have the following problem: The data structure I need to pass to a DLL function call has a structure variable inside its...
2
by: David | last post by:
Hi all, using 1.1 I am creating a dynamic menu structure for my site, however, I may refer to the structure many times within a page. This would be fine if I was doing it all in the...
6
by: Aston Martin | last post by:
Hi All, ********************** My Situation ********************** I am working on project that involves passing a structure to unmanaged code from .Net world (well using C#). Perhaps an example...
0
by: rocckky | last post by:
Hi, i am new to .NET framework so not that knowledgable about managed and unmanaged codes. The problem i am facing is i need to call a function say fun_test(struct test * A) which is present in...
4
by: eBob.com | last post by:
In my class which contains the code for my worker thread I have ... Public MustInherit Class Base_Miner #Region " Delegates for accessing main UI form " Delegate Sub DelegAddProgressBar(ByVal...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.