PDA

View Full Version : Registry


1skram323
04-26-2007, 01:11 PM
I am having issues trying to copy files to a cd burner

when I try this on my laptop with one user it works great, but i try to run it
on an xp machine with multiple user accounts it gets lost.


test = (Shell.GetFolder(SHF_APPLICATIONDATA).."Microsoft\\CD Burning");
sFolder = (Shell.GetFolder(SHF_MYDOCUMENTS).."\\New Folder");

--CurrentUser = Registry.GetValue(USERPROFILE,"Software\\Microsoft\\Windows\\CurrentVersion\\Expl orer\\Shell Folders", "CD Burning", true);

StatusDlg.Show(MB_ICONNONE, false);

File.Copy(sFolder, test, true, true, false, true, nil);

error = Application.GetLastError();
StatusDlg.Hide();

if error ~= 0 then
result = Dialog.Message("Error", "There was an error copying the files to your system. Please try again."
, MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
else
File.Open(Shell.GetFolder(SHF_APPLICATIONDATA_COMM ON).."\\Microsoft\CD Burning", "", "", SW_SHOWNORMAL, false);
end

RizlaUK
04-26-2007, 01:39 PM
try it with "SHF_APPLICATIONDATA" rather than "SHF_APPLICATIONDATA_COMMON"

SHF_APPLICATIONDATA

The path to the Application Data folder on the user's system. On Windows NT/2000/XP, this is the path from the per-user profile. Typically, this is something like "C:\Documents and Settings\YourName\Application Data." On Windows Vista, this is something like "C:\Users\YourName\AppData\Roaming."

SHF_APPLICATIONDATA_COMMON

The path to the Application Data folder on the user's system. On Windows NT/2000/XP/Vista, this is the path from the All Users profile. On a non-Windows NT system, this will be the path to the user's Application Data folder (same as SHF_APPLICATIONDATA)

1skram323
04-26-2007, 02:37 PM
RizlaUK,
Thank you for the quick response! I had already tried to use the SHF_APPLICATION and didn't have any luck. the problem might be in the
way I am referencing the location.

here is the file location, but I don't want to hard code the user considering there
are other people that could use it.


C:\Documents and Settings\user\Local Settings\Application Data\Microsoft\CD Burning


Thanks again
Mark

Tek
04-26-2007, 02:43 PM
Maybe add this?


test = (Shell.GetFolder(SHF_APPLICATIONDATA).."\\Microsoft\\CD Burning");

RizlaUK
04-26-2007, 03:04 PM
OMG.....

how did i miss that, guess iv been staring at code for to long and need a break

i spot another fault :eek: see tek's on first line and also look at last line

test = (Shell.GetFolder(SHF_APPLICATIONDATA).."\\Microsoft\\CD Burning");
sFolder = (Shell.GetFolder(SHF_MYDOCUMENTS).."\\New Folder");

--CurrentUser = Registry.GetValue(USERPROFILE,"Software\\Microsoft\\Windows\\CurrentVersion\\Expl orer\\Shell Folders", "CD Burning", true);

StatusDlg.Show(MB_ICONNONE, false);

File.Copy(sFolder, test, true, true, false, true, nil);

error = Application.GetLastError();
StatusDlg.Hide();

if error ~= 0 then
result = Dialog.Message("Error", "There was an error copying the files to your system. Please try again."
, MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
else
File.Open(Shell.GetFolder(SHF_APPLICATIONDATA_COMM ON).."\\Microsoft\\CD Burning", "", "", SW_SHOWNORMAL, false);
end

1skram323
04-26-2007, 03:21 PM
I fixed the (SHF_APPLICATIONDATA).."\\Microsoft

still nothing.

Correct me if I am wrong please I am a newbie, but the

SHF_APPLICATIONDATA only access the folders that are located in the app data folder

Application Data\Microsoft\CD Burning

I think that the code is stopping when it hits this part

C:\Documents and Settings\user\Local Settings\

and never makes it to the app data\cd burn folder.

Is there a way to pull the user out of the registry and use that value to fill in the user so that the application gets the info on its own?

Thanks All!

RizlaUK
04-26-2007, 04:27 PM
right, its because "SHF_APPLICATIONDATA" is returning the wrong path

C:\Documents and Settings\User\Application Data

the path to the "CD Burning" folder is

C:\Documents and Settings\User\Local Settings\Application Data\Microsoft\CD Burning

so try this:


test = (Shell.GetFolder(SHF_APPLICATIONDATA));
result = String.Replace(test, "Application Data", "Local Settings\\Application Data\\Microsoft\\CD Burning", false);

output enhanced with AMS Code Pretty (http://www.indigorose.com/forums/showthread.php?t=19409)

1skram323
04-26-2007, 10:27 PM
I tried that also and no luck, I do appreciate all of the help with this!:D :yes

If anyone has time to take a look at this thread and let me know it this will
apply to AMS also.
________________________________________________

INFO: Finding Shell Folders in the Registry
Document ID: IR02021The information in this article applies to:

* Setup Factory 6.0

http://www.indigorose.com/forums/showthread.php?t=5012
__________________________________________________

I am going to play with it for a while to see what I get.

RizlaUK
04-27-2007, 05:05 AM
ok, now im fully awake i might see things a bit clearer


File.Copy(sFolder, test, true, true, false, true, nil);

should be

File.Copy(sFolder.."\\*.*", test, true, true, false, true, nil);

i just ran a test and the below code copy's the files to the cd burning folder of the current user, i even get the balloon tip asking if i want to burn the files now :yes


test = (Shell.GetFolder(SHF_APPLICATIONDATA));
test = String.Replace(test, "Application Data", "Local Settings\\Application Data\\Microsoft\\CD Burning", false);

sFolder = (Shell.GetFolder(SHF_MYDOCUMENTS).. "\\New Folder");
StatusDlg.Show(MB_ICONNONE, false);

File.Copy(sFolder.. "\\*.*", test, true, true, false, true, nil);
error = Application.GetLastError();
StatusDlg.Hide();

if error ~= 0 then
result = Dialog.Message( "Error", "There was an error copying the files to your system. Please try again.", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
else
File.Run( "Explorer", test, "", SW_SHOWNORMAL, false);
end

output enhanced with AMS Code Pretty (http://www.indigorose.com/forums/showthread.php?t=19409)

1skram323
04-27-2007, 08:33 AM
RizlaUK,

If and when you have time I think this thread explains my problem the best, I am not sure if there was ever a solution found or not. I submitted a post to see.

http://www.indigorose.com/forums/showthread.php?t=16516&highlight=current+user

I attached a .jpg showing the exact file loaction if it helps?

I am at work so I will probebly have to try more this afternoon.

Thanks!
Mark

qwerty
06-15-2007, 02:46 PM
i could be wrong here (and probably am).... but doesnt the SHF_APPLICATIONDATA returned path only have single "\" in it, so where you have altered it to "\\" in your hard coding, i "think" that you have to also alter the returned path.

easiest way i found to do this was to get the whole path sorted first with single \ then convert it to \\ using

AMS_compatible_format = String.Replace(YOUR PATH VARIABLE HERE, "\\", "\\\\", false);

Desolator
06-15-2007, 09:51 PM
Do not replace \ with \\ in variables unless you are creating them, as that WILL be rendered as \\. If you are creating a string then use \\, eg:

This is correct:
CallFunction("C:\\My Folder");

This is wrong:
CallFunction(String.Replace(strMyPath, "\\", "\\\\", false));

qwerty
06-16-2007, 01:28 AM
ok, i stand corrected (not an uncommon event!) i just remember having trouble with using paths as strings once and that solved the issue i was having.