Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not using the Common Dialog control

Status
Not open for further replies.

petermeachem

Programmer
Aug 26, 2000
2,270
GB
I'm told by my customer that me using version 6 of the common dialog ocx has stopped some other programme of theirs from working, which uses version 5. Apparently the german authors cant see any way they could have made an error, so I've recoded using api instead of ocx.
This was OK until it got to making the selected printer the default. I found this huge wadge of code at Microsoft :-
FIX: Setting Printer to Item in the Printers Collection Fails
Last reviewed: July 3, 1998
Article ID: Q167735

It worked on NT, but not on Win98. I bodged the following section of code so that it did work. Can anyone explain the if's here. What numbers come up for various OS's and what happens on win2000, cos I haven't got that.

Dim osinfo As OSVERSIONINFO
Dim retvalue As Integer

osinfo.dwOSVersionInfoSize = 148
osinfo.szCSDVersion = Space$(128)
retvalue = GetVersionExA(osinfo)

If osinfo.dwMajorVersion = 3 And osinfo.dwMinorVersion = 51 And _
osinfo.dwBuildNumber = 1057 And osinfo.dwPlatformId = 2 Then
Call WinNTSetDefaultPrinter
ElseIf osinfo.dwMajorVersion = 4 And osinfo.dwMinorVersion = 0 _
And osinfo.dwBuildNumber = 67109814 And osinfo.dwPlatformId = 1 _
Then
Call Win95SetDefaultPrinter
ElseIf osinfo.dwMajorVersion = 4 And osinfo.dwMinorVersion = 0 _
And osinfo.dwBuildNumber = 1381 And osinfo.dwPlatformId = 2 Then
Call WinNTSetDefaultPrinter
End If
End Sub


 
The majorversion along with the minor version represent the version of Windows that is running the code (ie majorver=3 minorver=51 is referring to Windows 3.51 whereas majorver4 minorver=0 is NT 4.0) They could have left out the reference to the build since that could change on them and the platformid is the helps to identify whether its Win95 or 98 but then 98 can also be identified by majorver 4 with a minorver greater than 0.
Hope that helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top