CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 1999
    Location
    Austria
    Posts
    53

    Store Data in a dll

    Is it possible to store Data directly in a dll or exe Program.
    When yes how can I do this.

    mfG Pueromane


  2. #2
    Join Date
    May 1999
    Location
    Omika, Japan
    Posts
    729

    Re: Store Data in a dll

    Program related settings etc are usually stored in INI files (olden days), in Registry, these days.

    If bigger data exists, you can save it in local/ binary files, in special format etc.
    You can use Property bag object, specially for that purpose itself. You want to be really at the Front end of it Use XML to define your fromat, and save as XML data.

    But all these still save data OUTSIDE the exe. You cannot write into a exe/dll becuase , it will corrupt the program, and the sometimes the OS will keep a write-protection on the files, atleast while the program is running.

    RK

  3. #3
    Join Date
    May 1999
    Posts
    3,332

    Re: Store Data in a dll

    you can use the Resource Data to store data in your EXE or ActiveX DLL in VB.
    You can load these data at runtime via LoadResData.
    You can add these data with a text editor to create an RC file. Run it against the resource compiler to create RES file that you can add to your VB project.


  4. #4
    Join Date
    May 1999
    Location
    Omika, Japan
    Posts
    729

    Re: Store Data in a dll

    Hi Lothar,,
    I forgot abt it!:-) I dont know how i assumed that "data" necesarily meant read-write at run time!!! Thanks.

    RK

  5. #5
    Join Date
    Nov 1999
    Location
    Austria
    Posts
    53

    Re: Store Data in a dll

    When the user closes the program the data should be written into the dll or exe, so when the user starts the program again the data is shown on the form

    mfG Pueromane


  6. #6
    Join Date
    May 1999
    Location
    Omika, Japan
    Posts
    729

    Re: Store Data in a dll

    This is what you call "Program settings"
    You can use Registry to write them, under some key typically your application name.

    VB provides two functions for this purpose
    SaveSetting and GetSetting.
    A typical "last-login" data will be written like this

    SaveSetting( app.exename, "Last Login","ID", gszloginid)
    SaveSetting( app.exename, "Last Login","Name", gszloginname)



    On the next time start, you want to restore the login screen to show the last login name & id by default. so you say

    ' in Form load may be:
    gszloginid = GetSetting(app.exename,"Last Login","ID", VbNullString)
    gszloginname = GetSetting(app.exename,"Last Login","Name", VbNullString)
    txtLoginid.text = gszloginid
    txtloginName = gszloginname



    ---
    You dont write data "into" a dll. You can save in a specific format, in a predefined file name, typically under application installation directory. If the data is large this is preferable over writing into registry.

    For this purpose, like i said in my prev. post, you can use Property bag. ( A small correction: You dont need a user control. PropertyBag is provided by "VBRun" time)
    so you can directly use
    Or Use INI file, or any file format, or XML.

    RK

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