[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

API Question

Posted on 1998-06-03
11
Medium Priority
?
277 Views
Last Modified: 2010-05-03
I am using the following entry out of the win32api

Declare Function GetTimeZoneInformation Lib "kernel32" Alias "GetTimeZoneInformation" (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long

I have the following type set up

Type TIME_ZONE_INFORMATION
    zone As Long
End Type

Then in my sub I am doing this

Dim TimeZone As TIME_ZONE_INFORMATION
GetTimeZoneInformation TimeZone     it is this line that is causing the problem

Every time I try to run this it kills VB.  What am I doing wrong.  I have called into the API this way before.
0
Comment
Question by:jaalex
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +1
11 Comments
 

Author Comment

by:jaalex
ID: 1462487
Edited text of question
0
 
LVL 4

Expert Comment

by:yowkee
ID: 1462488
The normal declaration TIME_ZONE_INFORMATION should be:

Type SYSTEMTIME
        wYear As Integer
        wMonth As Integer
        wDayOfWeek As Integer
        wDay As Integer
        wHour As Integer
        wMinute As Integer
        wSecond As Integer
        wMilliseconds As Integer
End Type

Type TIME_ZONE_INFORMATION
        Bias As Long
        StandardName(32) As Integer
        StandardDate As SYSTEMTIME
        StandardBias As Long
        DaylightName(32) As Integer
        DaylightDate As SYSTEMTIME
        DaylightBias As Long
End Type
0
 
LVL 4

Expert Comment

by:yowkee
ID: 1462489
jaalex,

  Have you ever call this API in this way in VB? Or in C/C++? What GetTimeZoneInformation's parameter required is a pointer to TIME_ZONE_INFORMATION structure. If you just pass a long type variable into the API with byref, it will cause unpredicted result(who knew what would the memory address from that long variable!). That why you'll get GPF when you run it in VB.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Expert Comment

by:raygibbins
ID: 1462490
Your declarations should look like this

Option Explicit
Type SYSTEMTIME
        wYear As Integer
        wMonth As Integer
        wDayOfWeek As Integer
        wDay As Integer
        wHour As Integer
        wMinute As Integer
        wSecond As Integer
        wMilliseconds As Integer
End Type
Type TIME_ZONE_INFORMATION
        Bias As Long
        StandardName(32) As Integer
        StandardDate As SYSTEMTIME
        StandardBias As Long
        DaylightName(32) As Integer
        DaylightDate As SYSTEMTIME
        DaylightBias As Long
End Type

Declare Function GetTimeZoneInformation Lib "kernel32" (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long

Put the following code on a form, run the prog, and click the form, and get a message box showing weekday

Option Explicit

Private Sub Form_Click()
    Dim TimeZone As TIME_ZONE_INFORMATION
    GetTimeZoneInformation TimeZone
    MsgBox CStr(TimeZone.StandardDate.wDayOfWeek)
End Sub

0
 
LVL 4

Expert Comment

by:yowkee
ID: 1462491
raygibbins,

  Anythings different between your "answer" and my comments???
0
 
LVL 1

Expert Comment

by:raygibbins
ID: 1462492
yowkee,

Not really, but it works, so why is it not accepted yet?
0
 
LVL 4

Expert Comment

by:yowkee
ID: 1462493
raygibbins,

  Please look carefully! I am not the one to ask the question. And you should not post an answer which same as my comment.
  It just like taking other comment and post as answer.
0
 

Author Comment

by:jaalex
ID: 1462494
Sorry I posted the question and I have been out of town.  I belive that you raygibbins has copied the same thing that yowkee said.  That is why I am rejecting you answer.   Yowkee please answer and I will award you points

0
 
LVL 4

Accepted Solution

by:
yowkee earned 200 total points
ID: 1462495
Thanks, jaalex. :)

Answer as my comment.
0
 

Author Comment

by:jaalex
ID: 1462496
Sorry for talking so long on grading this.  I
0
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1462497
Bought This Question.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question