hey guy's, new day, new program and new problems...
I've created this autorun for my external hard drive, everything works perfectly, but i want some extras...
i want know if someone can supply some coding for me for when i insert the hard drive via usb and the autorun starts that the usb hard drive will be removed in my computer.
i think you going to need some .dll files for it, but i don't know how to work with .dll files yet.
can some maybe help and thanks to all the guys who is always helping
Comments
but theres is n problem somewhere, plus i still need to get some code to hide the external hard drive connected via USB...
now this is my code for the system tray icon.
//----------------------------------------------------
with TrayIconData do
begin
cbSize := SizeOf(TrayIconData);
Wnd := Handle;
uID := 0;
uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP;
uCallbackMessage := [color=Red]WM_ICONTRAY;[/color]
hIcon := Application.Icon.Handle;
StrPCopy(szTip, Application.Title);
end;
Shell_NotifyIcon(NIM_ADD, @TrayIconData);
//----------------------------------------------------
but it gives me an error at the red...
Undeclared identifier: 'WM_ICONTRAY'
can someone help please
forgot to declare the const...
const
WM_ICONTRAY = WM_USER + 1;
you need to add Registry to your uses clause just after interface
//--------------------------------
Procedure DriveControl;
Const
UserKeyHideDrive = 'HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer';
SystemKeyHideDrive = 'HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer';
UserKeyPreventAcces = 'HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer';
SystemKeyPreventAcces = 'HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer';
Begin
With TRegistry.Create Do
Try
If OpenKey(UserKeyHideDrive, True) Then
WriteInteger('NoDrives', X);
If OpenKey(SystemKeyHideDrive, True) Then
WriteInteger('NoDrives', X);
If OpenKey(UserKeyPreventAcces, True) Then
WriteInteger('NoDrives', X);
If OpenKey(SystemKeyPreventAcces, True) Then
WriteInteger('NoDrives', X);
CloseKey;
Finally
Free;
End;
End;
//--------------------------------------------------
Now... Where the x stands in WriteInteger('NoDrives', X) you have to enter in the Decimal code of the drive letter... example
A: 1, B: 2, C: 4,
but there is still some work...
if plug in my external hard drive, the autorun program starts showing the system tray icon and menus to control the drive... but the drives is still shown in my computer, u have to first log of or restart the computer before it hides the drives and the contents as i wanted...
is there some way to update or refresh the the explorer so that i don't need to restart or log of... o' and when i restart my anti virus program is always asking if i want windows registry to be accessed and if i say no the drive will be hidden, but when i say yes the registry will be restored and the drives is no longer hidden
Here we go...
you need to add Registry and windows to your uses clause just after interface if your using a unit
Procedure DriveControl;
Const
UserKeyHideDrive = 'SoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer';
LocalKeyHideDrive = 'SoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer';
UserKeyNoViewOnDrive = 'SoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer';
LocalKeyNoViewOnDrive = 'SoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer';
Begin
With TRegistry.Create Do
Try
RootKey := HKEY_CURRENT_USER;
If OpenKey(UserKeyHideDrive, True) Then
WriteInteger('NoDrives', 4);
If OpenKey(UserKeyNoViewOnDrive, True) Then
WriteInteger('NoViewOnDrive', 4);
CloseKey;
Finally
Free;
End;
With TRegistry.Create Do
Try
RootKey := HKEY_LOCAL_MACHINE;
If OpenKey(LocalKeyHideDrive, True) Then
WriteInteger('NoDrives', 4);
If OpenKey(LocalKeyNoViewOnDrive, True) Then
WriteInteger('NoViewOnDrive', 4);
CloseKey;
Finally
Free;
End;
End;
:
: Here we go...
:
: you need to add Registry and windows to your uses clause just after
: interface if your using a unit
:
[code]
: Procedure DriveControl;
: Const
: UserKeyHideDrive =
: 'SoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer';
: LocalKeyHideDrive =
: 'SoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer';
:
: UserKeyNoViewOnDrive =
: 'SoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer';
: LocalKeyNoViewOnDrive =
: 'SoftwareMicrosoftWindowsCurrentVersionPoliciesExplorer';
: Begin
: With TRegistry.Create Do
: Try
: RootKey := HKEY_CURRENT_USER;
: If OpenKey(UserKeyHideDrive, True) Then
: WriteInteger('NoDrives', 4);
: If OpenKey(UserKeyNoViewOnDrive, True) Then
: WriteInteger('NoViewOnDrive', 4);
: CloseKey;
: Finally
: Free;
: End;
:
: With TRegistry.Create Do
: Try
: RootKey := HKEY_LOCAL_MACHINE;
: If OpenKey(LocalKeyHideDrive, True) Then
: WriteInteger('NoDrives', 4);
: If OpenKey(LocalKeyNoViewOnDrive, True) Then
: WriteInteger('NoViewOnDrive', 4);
: CloseKey;
: Finally
: Free;
: End;
: End;
:
[/code]
Please use the code tags next time you post code. See below the entry box for new posts for instructions.
We would like to have our C# application that's been saved in an external hard drive to run automatically after we plugged in the external device. What are the codes that could make this work?