Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / execute file / registry

Author
Message
Mr Kohlenstoff
20
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 21st Sep 2011 15:36
Hi there,

I'm having some major problem on a, theoretically, trivial task.

This is my situation: I've written a small program that is meant to edit image files. In the directory of the program there's a 'settings.txt'-file. The problem is, however, that whenever I open an image with this program (via rightclick on the image file, 'open with...' -> my program's exe), the exe is started from another directory than the one it's in (either C:\windows\system32 - why?! - or the file of the image, depending on how I select the exe).

I then said to myself 'OK, no problem, let me just take the registry then to find out where DBPro is installed, this way I can find out where my settings.txt-file is'. So I opened regedit to find where DBP stores the install path, found it and tried to read this value:



And it totally worked. However, after compiling it again later (definitely without changing this line), it always returned an empty string instead of the DBP-path. I then tried everything, from using the absolute path (HKEY_LOCAL_MACHINE/SOFTWARE/Dark Basic/Dark Basic Pro) to regular expressions, but it never returns anything other than the empty string, no matter if I execute my exe as Admin or whatever.


So, all I really want is getting access to my settings.txt file that lies on a fixed location on my hard disk. I could, of course, hard code the path into my exe, but actually I was hoping to let others use the program as well without forcing them to use the exact same location for their files.
So, does anyone have an idea how I either convince windows Vista to run the exe in it's own directory (I have _no_ idea why it doesn't do that in the first place, that just seems so stupid and absolutely senseless to me), or how I can read the DBP-Install-path from the registry?

Thanks in advance. Help is greatly appreciated, I'm totally desperate right now...

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 21st Sep 2011 17:40
Double clicking works though right? So why not just let users double click the exe, and then you will see the image in the same directory?

Mr Kohlenstoff
20
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 21st Sep 2011 18:08 Edited at: 21st Sep 2011 18:15
The point is, you can rightclick on any image-file, press "Edit" and MS Paint (or GIMP or whatever program you use) opens that image. Opening the exe first would require to find it in your file system, open it, and then within the exe open the image you want to work on. However, I usually work with image files in many different locations. Always opening with the exe again really slows down the work flow (and would certainly result in me not using the program anymore).
In theory, I would just rightclick on any image file, say "open with my program" with another click and *BAM* there it is.

Principally it doesn't matter if I open the file using rightclick or doubleclick, same for the exe. It's just that when I open the image file directly (and that's what I want) with my program, the program is executed in the wrong directory, and I have no idea how to change that.

Edit: Hey I found a solution. The dbp-function 'appname$()' returns the name of the exe together with its original path. This way I can simply extract that string and move back there. Problem solved, case closed, thanks.

BUT I'd still like to know how to read the DBP-Install-Path from the registry, because using the DBP compiler is part of the programs functionality. I could solve that problem by writing the path into a file in my programs directory, but reading the path from the registry would be more user friendly I guess.

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 21st Sep 2011 18:13 Edited at: 21st Sep 2011 18:15
Oh I see, I thought you wanted images loaded from the directory that your exe was in.

IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 21st Sep 2011 23:53


Note: This obviously won't work for you if you transferred your DBPro directory to your current machine instead of installing it.

Mr Kohlenstoff
20
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Germany
Posted: 22nd Sep 2011 02:01 Edited at: 22nd Sep 2011 02:02
Ouch. I didn't expect that using "/" instead of "\" would make a difference - I mean, I tried it nontheless, but seemingly not in combination with starting the path with SOFTWARE (I tried computer/..., HKEY_LOCAL_MACHINE/..., Dark Basic/... and probably lost patience ).
Thank you very much, I didn't think the solution was really that simple. Everything works completely fine now, I'll post the result on the WIP-board within the next days.

Login to post a reply

Server time is: 2026-07-11 10:26:16
Your offset time is: 2026-07-11 10:26:16