Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / COM / July 2008



Tip: Looking for answers? Try searching our database.

Executable for other OSs

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter Hibbs - 10 Jul 2008 10:00 GMT
I have written a small VB6 executable program which I plan to publish
on the Internet. I know it works OK on Windows XP (and I assume Vista
also, although I haven't yet tested that) because the VB run time code
comes with those OSs. I don't want to distribute it using some
complicated Install program, I just want the end user to copy it to
their hard drive and be able to run it immediately, which it does.

My question is, if someone wants to install the program on some other
OS such as Win 98, Win ME, Win NT, etc (although this is fairly
unlikely) what other files would they need to obtain, where would they
get them from and how would they install them.

Peter Hibbs.
MikeD - 10 Jul 2008 12:29 GMT
>I have written a small VB6 executable program which I plan to publish
> on the Internet. I know it works OK on Windows XP (and I assume Vista
[quoted text clipped - 7 lines]
> unlikely) what other files would they need to obtain, where would they
> get them from and how would they install them.

Presumably , your program does not require any dependencies other than the core VB6 runtime files.  Win98, WinME, and WinNT do not
include the runtime files, though users may already have them from other programs they have installed or possibly even from updates
from MS (via Windows Update).  You can instruct users who do not have the runtime installed  to download it from MS.  Here is a
link:

VBRun60sp6.exe installs Visual Basic 6.0 SP6 run-time files
http://support.microsoft.com/kb/290887/en-us

Note that if your program DOES use other components (OCXs or DLLs, for example), it is not as likely users will already have
these....and even if they do, they could be older versions.  So it's best to have a Setup program that at least installs these along
with your program even if you choose not to redistribute the core VB6 runtime files.

Also, do not assume your program works under Vista just because it works under XP.  There are many security differences in Vista
that can break an app not written properly.  XP has much of the same security, but Vista enforces it more than XP (notably, for
members of the Administrators group).  If Vista users are going to be using your app, you need to test it thoroughly under Vista.

Signature

Mike
Microsoft Visual Basic MVP

Peter Hibbs - 10 Jul 2008 16:31 GMT
Mike,

Thanks very much, that is just what I wanted.

Regarding ActiveX controls, I am only using the Common Dialog control
to show the user the standard File Selector form on start up. I
believe this comes with the VB Run time file (hopefully).

I have access to Vista so I will try it on that system shortly, if I
have any problems I will post back.

Thanks again for your help.

Peter.

>>I have written a small VB6 executable program which I plan to publish
>> on the Internet. I know it works OK on Windows XP (and I assume Vista
[quoted text clipped - 23 lines]
>that can break an app not written properly.  XP has much of the same security, but Vista enforces it more than XP (notably, for
>members of the Administrators group).  If Vista users are going to be using your app, you need to test it thoroughly under Vista.
MikeD - 10 Jul 2008 18:40 GMT
> Mike,
>
[quoted text clipped - 3 lines]
> to show the user the standard File Selector form on start up. I
> believe this comes with the VB Run time file (hopefully).

No, it doesn't.  It is  a separate OCX file.

Signature

Mike
Microsoft Visual Basic MVP

Peter Hibbs - 10 Jul 2008 19:00 GMT
Mike,

Oh! I wonder if there is any way to provide a File Selector form,
using only code, that doesn't require an ActiveX control?

Peter.

>> Mike,
>>
[quoted text clipped - 5 lines]
>
>No, it doesn't.  It is  a separate OCX file.
Nico Notter - 11 Jul 2008 13:33 GMT
> Oh! I wonder if there is any way to provide a File
> Selector form,
> using only code, that doesn't require an ActiveX control?

The ActiveX control isn't more than a wrapper for some
WinAPI calls, so you can easily replace the Common Dialog
ActiveX file selection function by an appropriate WinAPI
call. There are many examples showing this,
planet-source.com is your friend. Then the remaining
question is only if the function will work for all requested
windows systems, I would guess so.
Jim Carlock - 12 Jul 2008 00:53 GMT
"Nico Notter" posted:
: The ActiveX control isn't more than a wrapper for some
: WinAPI calls, so you can easily replace the Common Dialog
: ActiveX file selection function by an appropriate WinAPI
: call.

Just curious about this. If EASILY is the word, could YOU post
some demonstration code?

Signature

Jim Carlock
Natural Cure For Pink-Eye (Conjunctivitis) (no antibiotics needed)
http://www.associatedcontent.com/article/381336/saliva_a_natural_cure_for_conjun
ctivitis.html

Dmitriy Shulman - 14 Jul 2008 19:37 GMT
For file related code and many others I go to http://vbnet.mvps.org. It has
everything you need. Plenty of code samples/demos.

> "Nico Notter" posted:
> : The ActiveX control isn't more than a wrapper for some
[quoted text clipped - 4 lines]
> Just curious about this. If EASILY is the word, could YOU post
> some demonstration code?

http://www.associatedcontent.com/article/381336/saliva_a_natural_cure_for_conjun
ctivitis.html

Nico Notter - 15 Jul 2008 15:26 GMT
especially for all my friends without access to google:

Option Explicit

Type openFilename
   lStructSize             As Long
   hwndOwner               As Long
   hInstance               As Long
   lpstrFilter             As String
   lpstrCustomFilter       As String
   nMaxCustFilter          As Long
   nFilterIndex            As Long
   lpstrFile               As String
   nMaxFile                As Long
   lpstrFileTitle          As String
   nMaxFileTitle           As Long
   lpstrInitialDir         As String
   lpstrTitle              As String
   Flags                   As Long
   nFileOffset             As Integer
   nFileExtension          As Integer
   lpstrDefExt             As String
   lCustData               As Long
   lpfnHook                As Long
   lpTemplateName          As String
End Type

Private Declare Function GetOpenFileName Lib "comdlg32.dll"
Alias "GetOpenFileNameA" (pOpenfilename As openFilename) As
Long

Public Function ShowOpen(filename As String, pathname As
String, filter As String, title As String) As String

   Const OFN_FILEMUSTEXIST = &H1000
   Const OFN_EXPLORER = &H80000

   Dim flag            As Long
   Dim OFN             As openFilename

   flag = OFN_EXPLORER Or OFN_FILEMUSTEXIST

   OFName.lStructSize = Len(OFName)
   OFName.hwndOwner = Screen.ActiveForm.hWnd
   OFName.hInstance = App.hInstance
   OFName.lpstrFilter = filter
   OFName.lpstrFile = left$(filename & Space$(254), 254)
   OFName.nMaxFile = 255
   OFName.lpstrFileTitle = String(254, vbNullChar)
   OFName.nMaxFileTitle = 255
   OFName.lpstrInitialDir = pathname
   OFName.lpstrTitle = title
   OFName.Flags = flag

   If GetOpenFileName(OFName) = 0 Then
           ShowOpen = ""
       Else
           ShowOpen = StripNullChar(OFName.lpstrFile)
       End If

End Function

Private Function StripNullChar(Buffer As String) As String

   Dim NullPos             As Integer

   NullPos = InStr(Buffer, vbNullChar)
   If NullPos > 0 Then
       StripNullChar = left$(Buffer, NullPos - 1)
   Else
       StripNullChar = Buffer
   End If

End Function
Peter Hibbs - 12 Jul 2008 09:18 GMT
Nico

Found some useful code on the site but not specifically for opening
the File Selector dialog. Will have another dig around later. Thanks
again.

Peter.

>> Oh! I wonder if there is any way to provide a File
>> Selector form,
[quoted text clipped - 7 lines]
>question is only if the function will work for all requested
>windows systems, I would guess so.
Peter Hibbs - 12 Jul 2008 12:54 GMT
I have found a site which seems to do exactly what I want with a small
amount of code. See
http://www.visualbasic.happycodings.com/Common_Dialogs/code6.html
for more info.

However, I believe the method to call the BrowseForFile function
should be something like this.
'--------------------------------------------------------------------------
Sub Test()

Dim strFilename As String

   strFilename = BrowseForFile("C:\", "Excel File (*.xls);*.xls",
"Open Workbook")
   if strFilename = "" Then End

End Sub
'--------------------------------------------------------------------------

I also changed the flags parameter in the code :-

   tFileBrowse.flags = 4

to hide the Read Only tick box on the dialog form.

The only slight problem is that it displays the File Selector dialog
in the top left corner of the screen, if anyone knows how to centre it
on the screen I would be very grateful.

Peter Hibbs.

>Nico
>
[quoted text clipped - 15 lines]
>>question is only if the function will work for all requested
>>windows systems, I would guess so.
Peter Hibbs - 13 Jul 2008 15:09 GMT
I am using the VB6 code from this site :-
http://www.visualbasic.happycodings.com/Common_Dialogs/code6.html
to open a File Dialog which works fine.

However, I want the dialog to show all files that end in .mdb AND .mde
and this bit is not working. I have tried various combinations of
commas and semi-colons but have not got it working yet. I am using
this string as the filter string in the above code :-

"Database Files (.mdb .mde),*.mdb;*.mde"

which shows only .mde files in the dialog and shows -

Database Files (.mdb .mde),*.mdb

in the Files of Type: field.

Does anyone know what string I should use to show multiple types of
files in the dialog.

Peter Hibbs.
Jim Carlock - 14 Jul 2008 17:08 GMT
: I am using the VB6 code from this site,
: http://www.visualbasic.happycodings.com/Common_Dialogs/code6.html
[quoted text clipped - 12 lines]
: Does anyone know what string I should use to show multiple
: types of files in the dialog.

"Database Files (.mdb, .mde)|*.mdb;*.mde"

Try the pipe character, |, to separate the different fields, and
use semicolons to separate and identify all the extensions. The
pipe character involves pressing the SHIFT key and the backslash
key on most English keyboards, but can be a little different for
any keyboard. You can also type it by holding an ALT key down and
typing 124 on the numeric keypad (make sure NumLock is activated).

If one were to show the string of parameters for the Common Dialog
fields, the string tends to look like,

sDescription | sExt1;sExt2;sExt3

where the whole string identified by the sDescription and the
associated file extensions looks like a following string:

Access MDB (*.mdb) | *.mdb
Access MDE (*.mde) | *.mde
Access, Any (*.mdb,*.mde) | *.mdb;*.mde

The fact that only .mde files show up seems to indicate that the
internals of the common dialog start reading the string from right
to left looking for the pipe character identifying the end of the
extensions and the start of the description.

Signature

Jim Carlock
Natural Cure For Pink-Eye (Conjunctivitis)
http://www.associatedcontent.com/article/381336/saliva_a_natural_cure_for_conjun
ctivitis.html

MikeD - 14 Jul 2008 19:10 GMT
> I am using the VB6 code from this site :-
> http://www.visualbasic.happycodings.com/Common_Dialogs/code6.html
[quoted text clipped - 15 lines]
> Does anyone know what string I should use to show multiple types of
> files in the dialog.

There's a bug in the example code.  Comment out the 2 lines which replace the pipe and semicolon characters:

   'sFileFilters = Replace(sFileFilters, "|", vbNullChar)
   'sFileFilters = Replace(sFileFilters, ";", vbNullChar)

Pass your filter string to the function as such (tested):

BrowseForFile("C:\", "Database Files (.mdb .mde)" & vbNullChar & "*.mdb;*.mde" & vbNullChar)

The semicolon in the above string which separates the 2 file patterns is important and must be left intact. The code was replacing
that with a null character and that was screwing everything up.

Not so sure I would trust code from that web site anymore. <g>

Signature

Mike
Microsoft Visual Basic MVP

Peter Hibbs - 14 Jul 2008 21:57 GMT
Mike,

That all works perfectly now, I was a bit suspicious of those two
lines but I don't know enough about the API structure to work out why
it was wrong.

Thanks very much for your help.

Peter.

>> I am using the VB6 code from this site :-
>> http://www.visualbasic.happycodings.com/Common_Dialogs/code6.html
[quoted text clipped - 29 lines]
>
>Not so sure I would trust code from that web site anymore. <g>
MikeD - 14 Jul 2008 19:35 GMT
>I have found a site which seems to do exactly what I want with a small
> amount of code. See
[quoted text clipped - 24 lines]
> in the top left corner of the screen, if anyone knows how to centre it
> on the screen I would be very grateful.

By default, the dialog is automatically positioned in the upper left corner of the window whose hWnd you pass for the lParentHwnd
parameter. If you're not passing an hWnd, it's going to display in the upper left of the screen. Moving the dialog to a specific
location of your choosing (such as centering it) is rather involved and to do "properly" requires using a hook procedure.

If you want to give this a shot, see the following, courtesy of Randy Birch:

http://vbnet.mvps.org/code/hooks/fileopensavedlghook.htm

Signature

Mike
Microsoft Visual Basic MVP

Peter Hibbs - 14 Jul 2008 21:59 GMT
Mike,

Thanks for the info, a lot to digest, I will study it later and see if
I can use it in my code (centreing the dialog is not a high priority
item at the moment).

Peter.

>>I have found a site which seems to do exactly what I want with a small
>> amount of code. See
[quoted text clipped - 32 lines]
>
>http://vbnet.mvps.org/code/hooks/fileopensavedlghook.htm
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.