CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14
  1. #1
    Join Date
    Jun 2010
    Posts
    18

    [RESOLVED] getting the .vbp filename in a vb project

    Hi,
    I need to get the .vbp file name of a project in vb6.0. This is required to read all the form names from it and get all the controls in that forms.

    Thanx

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: getting the .vbp filename in a vb project

    In .NET this is one line of code!!!

    I was thinking that you should Add a reference to Microsoft Development Environment 7.0 and then work from there. The problem is that I don't think that file is compatible with VB 6. In code view in VB 6 you will be able to access all the properties & methods, but I just can't seem to get something working. Maybe I should try again.

    Or, you could build a basic thing in VB.NEt and import that dll into your VB 6 project

  3. #3
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: getting the .vbp filename in a vb project

    Could be one line in VB6 as well. By default the vbp filename is the same as the exe filename other than the extension.

    Code:
    ProjectName=app.path &"\" & mid(app.exename,1,len(app.exename)-3) & "vpb"

    The vbp however is typically not part of the files that would be installed on the end users system so this file would not be available at runtime in most cases. Not sure why one would need to do this type of thing.

    One easy way of course would be to simply use dir$() and search app.path for *.vbp files most of the time there will be only one result. In cases where more than one project exist you could read a few lines from each to find the exe name for that project and match it to your app.exename
    Last edited by DataMiser; June 25th, 2010 at 08:02 AM.
    Always use [code][/code] tags when posting code.

  4. #4
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: getting the .vbp filename in a vb project

    Opps.. I was mistaken app.exename does not include the extension so it would be
    Code:
    ProjectName=app.path &"\" & app.exename &".vpb"
    Also app.title by default is the same as the project name so
    Code:
    ProjectName=app.path &"\" & app.title &".vpb"
    should work as well assuming that you have not changed this in the project properties.
    Always use [code][/code] tags when posting code.

  5. #5
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: getting the .vbp filename in a vb project

    I was overly complicated and complex again! HAHA! LOL!

  6. #6
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    Re: getting the .vbp filename in a vb project

    app.title is the bettr choice anyway, because the exename is not necessarily the name of the project. In many cases people kee the Project1 name, but give the exe a distinct name.

  7. #7
    Join Date
    Jun 2010
    Posts
    18

    Re: getting the .vbp filename in a vb project

    Hi,
    I am very unlucky because all the applications that I am working have their exe names changed to something. The title is set for all the applications to something different from the .vbp file name. Is there any other way to get the .vbp file name. Thanks to you all guys for your effort.

  8. #8
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: getting the .vbp filename in a vb project

    Like I menioned in the first post Dir$() with * .vbp as a filter will retrieve any .vbp files in the given folder. It you have only one project file per folder then this would work fine if you have more then you would need to parse the vbp files to find the right one for the program in question. Even then it should eb pretty simple.
    Always use [code][/code] tags when posting code.

  9. #9
    Join Date
    Apr 2009
    Posts
    394

    Re: getting the .vbp filename in a vb project

    Okay people, App.exename is the actual name of the exe on disk, change it and so does the return value. App.Title is the actual file name of the *.vbp file as saved on disk, change it, and so does the return value.

    Now, what it seem like the OP is after is the information contained within the *.vbp file... which is
    Code:
    Type=Exe
    Form=Form1.frm
    Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\Windows\system32\stdole2.tlb#OLE Automation
    IconForm="Form1"
    Startup="Form1"
    ExeName32="dummytest.exe"
    Command32=""
    Name="Test"
    HelpContextID="0"
    CompatibleMode="0"
    MajorVer=1
    MinorVer=0
    RevisionVer=0
    AutoIncrementVer=0
    ServerSupportFiles=0
    CompilationType=0
    OptimizationType=0
    FavorPentiumPro(tm)=0
    CodeViewDebugInfo=0
    NoAliasing=0
    BoundsCheck=0
    OverflowCheck=0
    FlPointCheck=0
    FDIVCheck=0
    UnroundedFP=0
    StartMode=0
    Unattended=0
    Retained=0
    ThreadPerObject=0
    MaxNumberOfThreads=1
    Which will allow someone experience at reading these files, find all of the other files associated with the project, and *.vbg files contain links to the *.vbp files. So one could make changes or as I have been doing, allow someone who does not have vb6 to see the vb6 project as one would at design time, code, icons, graphics included, and picture boxes for those controls that are not found/registered/etc. on the machine. Just a note on the graphics, if they have been added to the project at design time and not at runtime...



    Good Luck

  10. #10
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: getting the .vbp filename in a vb project

    Actually App.Title is the value assigned to App.Title in the properties window. By default it is the same as the VBP file. If you change the name of the VBP file the title changes as well. If you change the Title in the properties area then the VBP file is no longer a match.

    The only [almost] fool proof way that I can think of would be to look for VBP files in the project folder and if more than one exists then read the data from the file until you find the exename or title and compare that to what is returned. Even this could fail if the vbp has been modified since the exe was built.
    Always use [code][/code] tags when posting code.

  11. #11
    Join Date
    Dec 2007
    Posts
    234

    Re: getting the .vbp filename in a vb project

    What's the point? Are you planning on shipping the source code with the app? Unless you do, this is all irrelevant and pointless. And a lesson in futility.

    Now if you are building an app that needs to read the vbp info of other PROJECTS... then there's a way to work with that. But for an app to read it's own VBP file(s)... is another matter.

    -tg
    * I don't respond to private requests for help. It's not conducive to the general learning of others.-I also subscribe to all threads I participate, so there's no need to pm when there's an update.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help - how to remove eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to???
    * On Error Resume Next is error ignoring, not error handling(tm). * Use Offensive Programming, not Defensive Programming.
    "There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN
    MVP '06-'10

  12. #12
    Join Date
    Jun 2010
    Posts
    18

    Re: getting the .vbp filename in a vb project

    Hi,
    I am trying to get the properties of an activex control in all the forms of the project. So to access all the forms, I am getting the form names of the project through the .vbp file. Then I pass the name of the forms to Forms.Add and then load them and read all the required activex control properties. This exercise is done to know what are all the properties which are set for the activex control ( comparing them against the default property values for the activex control.)
    This has to be done for nearly 50 projects.
    Hope I am clear.

  13. #13
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: getting the .vbp filename in a vb project

    why not use Dir$() with *.frm as a filter? This would give you all the file names of all the forms in a given folder.

    Also why are you adding all these forms if all you want to do is grab the properties? You can read these from the frm file.
    Always use [code][/code] tags when posting code.

  14. #14
    Join Date
    Jun 2010
    Posts
    18

    Re: getting the .vbp filename in a vb project

    Thank you. I am reading it from the .frm file. Thanks for the suggestion. Hope I could be like you.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured