Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 20th, 2003, 01:18 PM
Authorized User
 
Join Date: Jun 2003
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default Pointers

I need to use a pointer to a variable in VB. I have looked for an API without success. Anyone out there know how to do it?.
 
Old June 20th, 2003, 01:32 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there..
why do you need to use pointers?? this is no C.. you dont have pointers.. or at least not declared like that..
maybe if you write what are you trying to acomplish we can help you???

Gonzalo Bianchi
 
Old June 20th, 2003, 01:38 PM
Authorized User
 
Join Date: Jun 2003
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for getting back to me.

I wanted to write back a variable to the .exe file. But now that you mention it I'd be better writing it to the .exe on the disc (while the .exe is runnuing!!). I will of course have to know the exact location and size.
 
Old June 20th, 2003, 01:46 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Now I am really interested! What is it you are trying to do? What is the motivation? Why do you want to write a variable back to the exe? I am not sure I understand what you are wanting to do?

Larry Asher
 
Old June 20th, 2003, 01:50 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi..

ehhh.. if it a variable it should change while the program is running.. and you have it on memory.. and have a pointer to it in the form you variable name..
if you want that value to be stored, you should try another method.. because your exe will not save the value of the variable.. just some form of pointer to know where in the memory it's in that moment.. and that pointer will change b/c windows page the programs.. so you never know where it is (in the case you found a way to retrieve the memory mapping)...

let's begin this again.. tell us what are you trying to accomplish doing this...

Gonzalo Bianchi
 
Old June 20th, 2003, 02:05 PM
Authorized User
 
Join Date: Jun 2003
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

easy enough - if I can write a number back to the disc within the .exe then I can get it to run a certain number of times before it no longer runs at all.
 
Old June 20th, 2003, 02:12 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

ah.. now we are talking.. you are trying to secure your program so they will have to pay u to use it... ;)

well.. then you will have to get a constant in your program.. and then rewrite the exe.. but it's not posible to write a file while it is running..
using the registry it's to tricky??????

if the program fails to start b/c a number was written on it.. i could simply recopy the program and start all over again...

Gonzalo Bianchi
 
Old June 20th, 2003, 02:16 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, I am still not sure what you mean by "back to the disc within the exe"?

However, I do think I know what you are trying to. It sound like you want to limit the number of times your program can be ran\executed. There are definitely more elaborate methods accomplish that. But, I will make two suggestion.

1. Try using the registry. You can read and write to the registry using the GetSetting() function and the SaveSetting() function respectively. You can look these functions up in your help file for more information.

2. Try writing the value to a text file. This is essentially what you are saying when you say write it back to disc. You can create a text file to any mapped drive including the A drive if you want to write it back to that disc. Read your help files for more information on creating, reading and writing text files.

I would probably go with the registry. But, in either case you are going to need a way to override this function.

Hope this helps.

Larry Asher
 
Old June 20th, 2003, 02:22 PM
Authorized User
 
Join Date: Jun 2003
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I wish it was good enough to merit payment :(

I am just playing around with ideas, wondering how the pros do it. I figured people wouldn't go down the copying path becasue they would get fed up having to copy the program after 3 goes.

If it's the registry I need to learn about then it's back to wrox books I go... Thanks for your help. :)
:)
 
Old June 20th, 2003, 02:32 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually, and not to be argumentative, using the registry is not that difficult. VB does a good job of hiding some of the intricacies. It also limits some of the functionality you can get going directly to the API Function calls. What I am saying is don't be overwhelmed by the word Registry. I know it is something we have all been taught to fear. But it is a valuable asset to the programmer and really not all that difficult to use for most functions you are going to perform.

I have used the registry to allow users to customize applications and to maintain configuration settings. Since, running a few applications in a Terminal Services solution. I have adopted a new philosophy. For the application configuration settings I will use an Ini file and for user settings which personalize the application I will use the registry. What I found in a TS environment is that each user has individual registry setting. I actually had to configure my application for each initial instance, no fun! But by using the combination I think it will give the ability to have a dynamic application all the way around.

I would suggest looking up the functions GetSetting() and SaveSetting() before throwing in the towel or thinking it is too complicated. You'll be surprised.

Hope this helps.

Larry Asher





Similar Threads
Thread Thread Starter Forum Replies Last Post
C/C++ Pointers reality_42000 C++ Programming 1 March 4th, 2007 01:26 AM
array and pointers amrinder C++ Programming 1 November 10th, 2006 07:58 AM
pointers Stuby085 Visual C++ 1 August 30th, 2003 11:58 PM
New to C++. Question about pointers jtodora Visual C++ 1 August 21st, 2003 10:28 PM
Pointers and Arrays C++ odie All Other Wrox Books 1 July 10th, 2003 01:45 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.