Skip to content

Commit

Permalink
Command line tweaks begun - added support for saved custom memory car…
Browse files Browse the repository at this point in the history
…d info to command line

Updated todo
Updated headers
Extracted a few string constants to Const unit where they should be
  • Loading branch information
bgbennyboy committed Oct 27, 2011
1 parent f02d7cc commit fa50080
Show file tree
Hide file tree
Showing 12 changed files with 188 additions and 178 deletions.
224 changes: 130 additions & 94 deletions USBDiskEject.dpr

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions formAbout.pas
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
******************************************************
USB Disk Ejector
Copyright (c) 2006 - 2010 Bgbennyboy
Copyright (c) 2006 - 2011 Bgbennyboy
Http://quick.mixnmojo.com
******************************************************
}
Expand Down Expand Up @@ -29,7 +29,6 @@ interface
Windows, Forms, Controls, Classes, Graphics,
ExtCtrls, JvExControls, JvScrollText,
JCLShell,
{uVistaFuncs,}
uDiskEjectConst, pngimage;


Expand Down Expand Up @@ -79,7 +78,7 @@ procedure TAboutfrm.FormShow(Sender: TObject);

procedure TAboutfrm.Image1Click(Sender: TObject);
begin
shellexec(0, 'open', 'Http://quick.mixnmojo.com/','', '', SW_SHOWNORMAL);
shellexec(0, 'open', 'Http://quick.mixnmojo.com','', '', SW_SHOWNORMAL);
end;

end.
70 changes: 6 additions & 64 deletions formMain.pas
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
******************************************************
USB Disk Ejector
Copyright (c) 2006 - 2010 Bgbennyboy
Copyright (c) 2006 - 2011 Bgbennyboy
Http://quick.mixnmojo.com
******************************************************
}
Expand Down Expand Up @@ -34,7 +34,7 @@
}

{
Added since beta 2:
Added since last stable release:
App instances - now only 1 allowed - launching second instance restores the first - only tested on vista
Made 'search for memory cards' enabled by default
DiskEjectUtils - CreateCleanupBatFileAndRun - removed legacy winexec and replaced with shellexec
Expand All @@ -51,8 +51,6 @@
Added /removelabel
Updated hotkey support with new commands
Fixed hotkeys still being removed in options dialog if cancel was pressed
Added since last stable release:
Firewire support - in gui + command line
Autosize window - resize doesnt go behind taskbar - sizes up if necessary - always stays on screen. Smart resizing
Autosize option
Expand Down Expand Up @@ -88,9 +86,6 @@
Need switch for command line card reader device - will eject card by default but not reader
Need to fix in start in mobile mode - need switch for eject card or card reader device
HOTKEYS:
need to know when restoring from ini - rebuildhotkeys - if hotkey active or not + to show this in options
OTHER:
Cant tab to the move label on main form
Windows 2000 support is broken
Expand All @@ -105,6 +100,7 @@
Use new Delph 2010 hints for all controls in options
If restarts in mobile mode and eject fails - load main app back up again somehow?
Customise what is displayed for each drive? Icon, colour, label etc
Hotkeys - need to know when restoring from ini - rebuildhotkeys - if hotkey active or not + to show this in options
Localisation
Card readers possible alternate detection? Use same method as windows rather than polling - is this available on all versions of windows though?
}
Expand Down Expand Up @@ -163,7 +159,6 @@ TMainfrm = class(TForm)
procedure TreeMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure JvAppInstances1Rejected(Sender: TObject);
procedure AddCustomCardReaders;
private
DrivePopups: array of TMenuItem;
Procedure MinimizeClick(Sender:TObject);
Expand Down Expand Up @@ -473,43 +468,13 @@ procedure TMainfrm.popupOptionsClick(Sender: TObject);

Ejector.CardPollingInterval := Options.CardPollingInterval;
Ejector.CardPolling:=Options.CardPolling;

if Options.MaxWidth >0 then
Mainfrm.Constraints.MaxWidth := options.MaxWidth
else
Mainfrm.Constraints.MaxWidth := null;

AddCustomCardReaders;

{if Options.ShowCardReaders then
begin //Might need to hide some drives
if Tree.RootNodeCount = Tree.VisibleCount then
FillDriveList;
end
else
begin //Some drives hidden when they shouldnt be
if Tree.RootNodeCount <> Tree.VisibleCount then
FillDriveList;
end;}

//Rescan if this has changed
{if Options.CardPolling <> Ejector.CardPolling then
begin
Ejector.CardPolling:=Options.CardPolling;
FillDriveList;
end;}


{if Options.HideCardReadersWithNoMedia then
begin //Might need to hide some drives
if Tree.RootNodeCount = Tree.VisibleCount then
FillDriveList;
end
else
begin //Some drives hidden when they shouldnt be
if Tree.RootNodeCount <> Tree.VisibleCount then
FillDriveList;
end;}

AddCustomCardReaders(CardReaders, Ejector);

FillDriveList; //Options probably changed - rather than lots of checking what option has changed just rescan no matter what
ResizeTree;
Expand Down Expand Up @@ -767,7 +732,7 @@ procedure TMainfrm.FillDriveList;
Tree.Selected[Tree.GetFirst]:=true;
end;

AddCustomCardReaders;
AddCustomCardReaders(CardReaders, Ejector);
ChangeDriveVisibility;
AddDrivePopups;
Tree.EndUpdate;
Expand Down Expand Up @@ -837,29 +802,6 @@ procedure TMainfrm.ChangeDriveVisibility;

end;

procedure TMainfrm.AddCustomCardReaders;
var
i, j: integer;
begin
if CardReaders = nil then exit;
if CardReaders.CardReadersCount = 0 then exit;

for I := 0 to CardReaders.CardReadersCount - 1 do
begin
for J := 0 to Ejector.DrivesCount - 1 do
begin
if (Trim(Ejector.RemovableDrives[J].VendorId) = CardReaders.CardReaders[i].VendorID) and
(Trim(Ejector.RemovableDrives[J].ProductID) = CardReaders.CardReaders[i].ProductID) and
(Trim(Ejector.RemovableDrives[J].ProductRevision) = CardReaders.CardReaders[i].ProductRevision) then
begin
Ejector.SetDriveAsCardReader(J, true);
break;
end;
end;
end;

end;

procedure TMainfrm.AddDrivePopups;
var
i: integer;
Expand Down
11 changes: 9 additions & 2 deletions formOptions.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ object Optionsfrm: TOptionsfrm
TabOrder = 0
OnButtonClicked = CategoryButtons1ButtonClicked
OnCategoryCollapase = CategoryButtons1CategoryCollapase
ExplicitLeft = -1
end
object PanelBack: TPanel
Left = 161
Expand All @@ -84,6 +83,10 @@ object Optionsfrm: TOptionsfrm
TabOrder = 0
object TabSheet1: TTabSheet
Caption = 'TabSheet1'
ExplicitLeft = 0
ExplicitTop = 0
ExplicitWidth = 0
ExplicitHeight = 0
object ScrollBox1: TScrollBox
Left = 0
Top = 0
Expand Down Expand Up @@ -476,6 +479,10 @@ object Optionsfrm: TOptionsfrm
object TabSheet4: TTabSheet
Caption = 'TabSheet4'
ImageIndex = 3
ExplicitLeft = 0
ExplicitTop = 0
ExplicitWidth = 0
ExplicitHeight = 0
object ScrollBox4: TScrollBox
Left = 0
Top = 0
Expand Down Expand Up @@ -630,7 +637,7 @@ object Optionsfrm: TOptionsfrm
Left = 72
Top = 288
Bitmap = {
494C01010700E803540430003000FFFFFFFF2110FFFFFFFFFFFFFFFF424D3600
494C01010700E803600430003000FFFFFFFF2110FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000C00000006000000001002000000000000020
0100000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
Expand Down
14 changes: 7 additions & 7 deletions formOptions.pas
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
******************************************************
USB Disk Ejector
Copyright (c) 2006 - 2010 Bgbennyboy
Copyright (c) 2006 - 2011 Bgbennyboy
Http://quick.mixnmojo.com
******************************************************
}
Expand All @@ -28,9 +28,9 @@ interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, Buttons, ExtCtrls, CategoryButtons, ImgList,
JvExComCtrls, JvHotKey, Character,
{uVistaFuncs,}
uDiskEjectOptions, uCustomHotKeyManager, uDiskEjectConst, JvExStdCtrls, JvEdit;
JvExComCtrls, JvHotKey, Character, JvExStdCtrls, JvEdit,

uDiskEjectOptions, uCustomHotKeyManager, uDiskEjectConst, uDiskEjectUtils;

type
TOptionsfrm = class(TForm)
Expand Down Expand Up @@ -175,7 +175,7 @@ procedure TOptionsfrm.FormCreate(Sender: TObject);

Options.CardReaders := CardReaders;
Options.RebuildCardReaders;
Mainfrm.AddCustomCardReaders; //Have to do this here - cant do it in Main form as it runs from FillDriveList which is called by Create() - which runs before options or anything else is created
AddCustomCardReaders(CardReaders, Ejector); //Have to do this here - cant do it in Main form as it runs from FillDriveList which is called by Create() - which runs before options or anything else is created
end;

procedure TOptionsfrm.FormShow(Sender: TObject);
Expand Down Expand Up @@ -405,7 +405,7 @@ procedure TOptionsfrm.btnAddCardReaderClick(Sender: TObject);

if CardReaders.AddCardReader(Trim(Ejector.RemovableDrives[comboboxCardReaderChoose.ItemIndex].VendorId), Trim(Ejector.RemovableDrives[comboboxCardReaderChoose.ItemIndex].ProductID), Trim(Ejector.RemovableDrives[comboboxCardReaderChoose.ItemIndex].ProductRevision)) = false then
begin
ShowMessage('Couldnt add card reader. Maybe its already in the list?');
ShowMessage(str_CardReader_Add_Error);
exit;
end;

Expand Down Expand Up @@ -450,7 +450,7 @@ procedure TOptionsfrm.btnAddHotKeyClick(Sender: TObject);

try
if formMain.HotKeys.AddHotKey(HotKey1.HotKey, TempHotKeyAction, HotKeyParam) = false then
ShowMessage('Couldnt assign hotkey')
ShowMessage(str_Hotkey_Assign_Error)
else
begin
case TCustomHotKey(HotKeys.HotKeys[listViewHotkeys.Items.Count]).HotKeyType of
Expand Down
2 changes: 1 addition & 1 deletion uCommunicationManager.pas
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
******************************************************
USB Disk Ejector
Copyright (c) 2006 - 2010 Bgbennyboy
Copyright (c) 2006 - 2011 Bgbennyboy
Http://quick.mixnmojo.com
******************************************************
}
Expand Down
2 changes: 1 addition & 1 deletion uCustomHotKeyManager.pas
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
******************************************************
USB Disk Ejector
Copyright (c) 2006 - 2010 Bgbennyboy
Copyright (c) 2006 - 2011 Bgbennyboy
Http://quick.mixnmojo.com
******************************************************
}
Expand Down
4 changes: 3 additions & 1 deletion uDiskEjectConst.pas
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
******************************************************
USB Disk Ejector
Copyright (c) 2006 - 2010 Bgbennyboy
Copyright (c) 2006 - 2011 Bgbennyboy
Http://quick.mixnmojo.com
******************************************************
}
Expand Down Expand Up @@ -90,8 +90,10 @@ interface
str_Hotkey_NoParam = 'No parameter given! Select or type an item into the combobox and try again.';
str_Hotkey = 'Hotkey: ';
str_Hotkey_Remove_Error = 'Error - could not remove hotkey!';
str_Hotkey_Assign_Error = 'Couldnt assign hotkey';
str_Hotkey_Cannot_Restore: string = 'Hotkey cannot be restored!' + #13 + 'Please report this.';
str_CardReader_Remove_Error = 'Error - could not remove card reader from list!';
str_CardReader_Add_Error = 'Couldnt add card reader. Maybe its already in the list?';

implementation

Expand Down
2 changes: 1 addition & 1 deletion uDiskEjectOptions.pas
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
******************************************************
USB Disk Ejector
Copyright (c) 2006 - 2010 Bgbennyboy
Copyright (c) 2006 - 2011 Bgbennyboy
Http://quick.mixnmojo.com
******************************************************
}
Expand Down
28 changes: 26 additions & 2 deletions uDiskEjectUtils.pas
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
******************************************************
USB Disk Ejector
Copyright (c) 2006 - 2010 Bgbennyboy
Copyright (c) 2006 - 2011 Bgbennyboy
Http://quick.mixnmojo.com
******************************************************
}
Expand All @@ -27,14 +27,15 @@ interface

uses Classes, sysutils, windows, forms, jclsysinfo, jclfileutils, jclshell,
JCLRegistry, dialogs, ShellAPI, JwaWindows,
uDiskEjectConst, uDriveEjector;
uDiskEjectConst, uDriveEjector, uCardReaderManager;

type
TTaskBarPos = (_TOP, _BOTTOM, _LEFT, _RIGHT, _NONE);

procedure CreateCleanupBatFileAndRun;
procedure StartInMobileMode(Parameters: string);
procedure RemoveReadOnlyFileAttribute(FileName: string);
procedure AddCustomCardReaders(CardReaders: TCardReaderManager; Ejector: TDriveEjector);
function GetTaskBarHeight: integer;
function GetTaskBarWidth: integer;
function GetTaskBarPos: TTaskBarPos;
Expand Down Expand Up @@ -113,6 +114,29 @@ procedure StartInMobileMode(Parameters: string);
end;
end;

procedure AddCustomCardReaders(CardReaders: TCardReaderManager; Ejector: TDriveEjector);
var
i, j: integer;
begin
if CardReaders = nil then exit;
if CardReaders.CardReadersCount = 0 then exit;

for I := 0 to CardReaders.CardReadersCount - 1 do
begin
for J := 0 to Ejector.DrivesCount - 1 do
begin
if (Trim(Ejector.RemovableDrives[J].VendorId) = CardReaders.CardReaders[i].VendorID) and
(Trim(Ejector.RemovableDrives[J].ProductID) = CardReaders.CardReaders[i].ProductID) and
(Trim(Ejector.RemovableDrives[J].ProductRevision) = CardReaders.CardReaders[i].ProductRevision) then
begin
Ejector.SetDriveAsCardReader(J, true);
break;
end;
end;
end;
end;


function MatchNameToMountPoint(Name: string): string;
var
i, DrivesCount: integer;
Expand Down
2 changes: 1 addition & 1 deletion uDriveEjector.pas
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
******************************************************
USB Disk Ejector
Copyright (c) 2006 - 2010 Bgbennyboy
Copyright (c) 2006 - 2011 Bgbennyboy
Http://quick.mixnmojo.com
******************************************************
}
Expand Down
2 changes: 1 addition & 1 deletion uProcessAndWindowUtils.pas
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
******************************************************
USB Disk Ejector
Copyright (c) 2006 - 2010 Bgbennyboy
Copyright (c) 2006 - 2011 Bgbennyboy
Http://quick.mixnmojo.com
******************************************************
}
Expand Down

0 comments on commit fa50080

Please sign in to comment.