[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Saving application Variable

Posted on 2004-11-25
Medium Priority
Last Modified: 2011-09-20
Hello everyone. I have an interesting application request here.


Some places a product order in a shopping cart of a file.
At the end of the check out process they download a EXE file that is a "download manager" and then they proceed to download the file. They can move this EXE to any other computer, and it will know what file to download.

I have the application....but how do you store/hold the customer ID in the application when it is distributed. I have seen this at BuyMusic.com. You buy a song, download the app at the checkout...and the app knows who you are and can download at other locations by just moving the app.

If I can just store the customer id in the app, that is all i would need.

Hope you can help!!!
Question by:blenett
  • 3
  • 2
  • 2
  • +3
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12677781
You can store the customer ID somewhere in the Windows Registry or Windows directory
LVL 11

Expert Comment

ID: 12677958
Use SaveSetting and GetSetting to store and retreive values from the VBA key in the registry:


 SaveSetting appname, section, key, setting

appname String expression containing the name of the application orproject to which the setting applies.
section    String expression containing the name of the section where the key setting is being saved.
key         String expression containing the name of the key setting being saved.
setting    Expression containing the value that key is being set to.

 GetSetting(appname, section, key[, default])

Same as above except default is used for when the key is not in the registry.

This Code example should explain it all. Add 2 command buttons, paste the following and run:

Private Sub Command1_Click()
msg = InputBox("Enter the cust id to store")
SaveSetting "TestApp", "TestSection", "CustID", msg
End Sub

Private Sub Command2_Click()
MsgBox GetSetting("TestApp", "TestSection", "CustID", "No Key Found")
Command1.Enabled = True
End Sub

Private Sub Form_Load()
Command1.Caption = "Save Value"
Command2.Caption = "Get Value"
Command1.Enabled = False
End Sub

Expert Comment

ID: 12678837

       I thinks it a difficult task to save data on a exe, unless you re-compile your application for every company that will use it, which is improper. Probably there is a login screen that must be filled up by the user that will identify them. Another probable way is to create a exe file from winzip which contains thet exe file and a file which contains identifier for the user during run time of your application.

      For the Music software. Normally you are required to registered to run this application. All the data will be either be save on registry or file for your idetity.
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.


Author Comment

ID: 12679156
Hello Omnicast,

Definately agree it is hard.....as far as the music sofware.....there is no login/registration on the app...and you can move the app anywhere...so registry is not involved.

I am thinking if they compile the app during the order process with customer id/order id
maybe with .NET command line compile??


Expert Comment

by:Joachim Carrein
ID: 12680132
let the program talk to a database, and let the user remember some kind of serial number.
that way only 1 exe is needed
LVL 13

Accepted Solution

iHadi earned 2000 total points
ID: 12686822
Hello blenett

For this sollution you need to write a program for editing your main exe before suppyling it to the user

The main idea is that the exe doesn't get affected if you add data to the end of the exe file so we'll write the customerID to the end of the main exe file using another program and we'll put a function in the main program to read this data

And of course the data will go anywhere the main exe goes

The function that reads the data from the end of the main exe should be pasted in the main program
This function asumes that the customerID is 6 bytes length and uses 4 bytes asure that this data is ours

Private Function GetCustomerID() As String
Dim myPath As String
Dim iData As String * 10

' Open the Me.Exe for binary access
myPath = App.Path
If Right(myPath, 1) <> "\" Then myPath = myPath & "\"
myPath = myPath & App.EXEName & ".exe"

' Read the Last 10 bytes
Open myPath For Binary As #1
    Get #1, FileLen(myPath) - 9, iData
Close #1

' Check if they are our information
If Left(iData, 4) = "~MD~" Then
    GetCustomerID = Mid(iData, 5, 6)
    GetCustomerID = ""
End If

End Function
' ==========================================

And if you want the function which writes to the exe please comment

Expert Comment

ID: 12688876
Hi  blenett,
     I have seen a way to write in the exe file. It was posted also here at the expert exchange. But the problem is more about software piracy. Check this post it might help you to understand more about writing data to exe file and reading it.


    I hope this might help you with your problem.


Author Comment

ID: 12693149
I will look into that example tonight.

Author Comment

ID: 12712257
Hey Guys I should be testing this this week.

The app to write to the exe....do you reccomend doing it in .ASP page or to write a tiny app and call it in .ASP page via shell.

also iHadi, let me know if you have the write portion of your read example.
LVL 13

Expert Comment

ID: 12721254
Hi Blenett,

Here's the 'write portion' that you asked for and I hope it will help


Private Sub PutCustomerID()
Dim myPath As String
Dim iData As String * 10
Dim DataToWrite As String * 6

DataToWrite = "test12"
' Open the Exe for binary access
myPath = YourExePath
Open myPath For Binary As #1
' Read the Last 10 bytes
    Get #1, LOF(1) - 9, iData
    ' Check if they are our information
    If Left(iData, 4) = "~MD~" Then
        ' Write the data only
        Put #1, LOF(1) - 5, DataToWrite
        ' Write the data with our verifing string
        Put #1, LOF(1), "~MD~" & DataToWrite
    End If
Close #1

End Sub


Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

868 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