黑莓OS5.0的程序

TXTLater V2.1定时发送短信邮件及打电话

http://www.bonashen.com/wp-content/uploads/2010/09/txtlater2.1/txtlater.jad

image image

File Manager Pro160

http://www.bonashen.com/wp-content/uploads/bbapps/FileManagerPro160/FileManagerPro.jad

image

BeamExplorer

http://www.bonashen.com/wp-content/uploads/bbapps/BeamExplorer/BeamExplorer.jad

image

关于verydoc doc2any工具的参数

官方的readme.txt文件说明

C:\>doc2any.exe
Convert *.DOC, *.DOCX, *.RTF, *.TXT, *.PPT, *.PPTX, *.XLS, *.XLSX files to PDF,
PS, EPS, SVG, SWF, XPS, HPGL, PCL, TIF, PNG, JPG, BMP, GIF, TGA, PCX, EMF, WMF,
etc. formats
Usage: DOC2Any [options] <in-file> [<out-file>]
  -useoffice <int>         : Use MS Office to render DOC,DOCX,RTF,TXT,PPT,PPTX,PPTS,PPTSX,XLS,XLSX formats
    -useoffice 0: Don’t use MS Office to convert DOC,DOCX,RTF,TXT,PPT,PPTX,XLS,XLSX formats
    -useoffice 1: Use MS Office to convert DOC,DOCX,RTF,TXT,PPT,PPTX,XLS,XLSX formats
  -useprinter              : Convert DOC files to other formats via virtual printer
  -multipagetif            : Create multipage TIFF format
  -showofficeui            : Show Office Windows during conversion
  -resetofficeview         : Reset Office View type to wdPrintView
  -password <string>       : Set open password for office documents
  -checkpwd                : Check if MS Word document contains an open password
  -noretry                 : Don’t try to re-convert failed office documents
  -delay <int>             : Delay some milliseconds before conversion
  -width <int>             : Set page width to PDF file
  -height <int>            : Set page height to PDF file
  -emfheight <int>         : Split a long HTML file by height
  -pageheight <int>        : Split a long HTML page by page height, same as -emfheight
  -pageh <int>             : same as -pageheight
  -ph <int>                : same as -pageheight
  -xres <int>              : Set X resolution to image file
  -yres <int>              : Set Y resolution to image file
  -bitcount <int>          : Set color depth for image conversion
  -compression <int>       : Set compression for TIFF image
    -compression 1     : NONE compression
    -compression 2     : CCITT modified Huffman RLE
    -compression 3     : CCITT Group 3 fax encoding (1d)
    -compression 4     : CCITT Group 4 fax encoding
    -compression 5     : LZW compression
    -compression 6     : OJPEG compression
    -compression 7     : JPEG DCT compression
    -compression 32773 : PACKBITS compression
    -compression 32809 : THUNDERSCAN compression
    -compression 88880 : 204×98  G4 ClassF TIFF
    -compression 88881 : 204×196 G4 ClassF TIFF
    -compression 88882 : 204×98  G3 ClassF TIFF
    -compression 88883 : 204×196 G3 ClassF TIFF
    -compression 88884 : CCITT Group 3 fax encoding (2d)
  -rotate <int>            : Rotate pages, 90, 180, 270
  -margin <string>         : Set page margin to PDF file
    -margin 10         : Set margin to 10pt to left
    -margin 10×10      : Set margin to 10pt to left,top
    -margin 10x10x10   : Set margin to 10pt to left,top,right
    -margin 10x10x10x10: Set margin to 10pt to left,top,right,bottom
  -pagelayout <int>        : Set page layout that is used when opening the document in adobe Reader
   -pagelayout 0: Use viewer’s default settings
   -pagelayout 1: SinglePage
   -pagelayout 2: OneColumn
   -pagelayout 3: TwoColumnLeft
   -pagelayout 4: TwoColumnRight
   -pagelayout 5: TwoPageLeft
   -pagelayout 6: TwoPageRight
  -viewpagemode <int>      : Set page mode that is used when opening the document in adobe Reader
    -viewpagemode 0: No page mode is applied, default option
    -viewpagemode 1: Show outline tree
    -viewpagemode 2: Show thumbnails
    -viewpagemode 3: Open the document in full-screen mode
    -viewpagemode 4: UseOC
    -viewpagemode 5: UseAttachments
  -vieweropt <int>         : Set viewer preferences to adobe Reader
    -vieweropt  1: HideToolBar
    -vieweropt  2: HideMenuBar
    -vieweropt  4: HideWindowUI
    -vieweropt  8: FitWindow
    -vieweropt 16: CenterWindow
    -vieweropt 32: DisplayDocTitle
    -vieweropt 64: Non-FullScreenPageMode, use -viewerval to set more options
  -viewerval <int>         : Additional values used by -vieweropt 64
    -vieweropt 64 -viewerval 1   : UseNone
    -vieweropt 64 -viewerval 2   : UseOutlines
    -vieweropt 64 -viewerval 4   : UseThumbs
    -vieweropt 64 -viewerval 1024: UseOC
  -viewerzoom <string>     : Set viewer zoom ratio to Adobe Reader
    -viewerzoom FitBH: Display pages to fit the width of its bounding box
    -viewerzoom FitH : Display pages to fit the width of page
    -viewerzoom Fit  : Display pages to fit window
    -viewerzoom FitV : Display pages to fit height of page
    -viewerzoom FitB : Display pages to fit its bounding box entirely
    -viewerzoom FitBV: Display pages to fit height of its bounding box
    -viewerzoom 25   : Display pages with magnification at 25%%
    -viewerzoom 50   : Display pages with magnification at 50%%
    -viewerzoom 1600 : Display pages with magnification at 1600%%
  -viewpage <string>       : set start page when opening it in Adobe Reader
  -view                    : View PDF file after creation
  -append <int>            : Append document to an existing PDF file
    -append 0: Overwrite if PDF file exists
    -append 1: Insert before first page if PDF file exists
    -append 2: Append to last page if PDF file exists
    -append 3: Rename filename if PDF file exists
  -producer <string>       : Set ‘producer’ to PDF file
  -creator <string>        : Set ‘creator’ to PDF file
  -subject <string>        : Set ‘subject’ to PDF file
  -title <string>          : Set ‘title’ to PDF file
  -author <string>         : Set ‘author’ to PDF file
  -keywords <string>       : Set ‘keywords’ to PDF file
  -openpwd <string>        : Set ‘open password’ to PDF file
  -ownerpwd <string>       : Set ‘owner password’ to PDF file
  -keylen <int>            : Key length (40 or 128 bit)
    -keylen 0:  40 bit RC4 encryption (Acrobat 3 or higher)
    -keylen 1: 128 bit RC4 encryption (Acrobat 5 or higher)
    -keylen 2: 128 bit RC4 encryption (Acrobat 6 or higher)
  -encryption <int>        : Restrictions
    -encryption    0: Encrypt the file only
    -encryption 3900: Deny anything
    -encryption    4: Deny printing
    -encryption    8: Deny modification of contents
    -encryption   16: Deny copying of contents
    -encryption   32: No commenting
    ===128 bit encryption only -> ignored if 40 bit encryption is used
    -encryption  256: Deny FillInFormFields
    -encryption  512: Deny ExtractObj
    -encryption 1024: Deny Assemble
    -encryption 2048: Disable high res. printing
    -encryption 4096: Do not encrypt metadata
  -unicode                 : Enable Unicode conversion
  -noempty                 : Delete empty pages from PDF file
  -killoffice <int>        : Kill or not kill MS Office instances before conversion
  -installprinter          : Install virtual printer only
  -printername <string>    : Alternate name for virtual printer on FILE: port
  -printername2 <string>   : Alternate name for virtual printer on LPT1: port
  -wtext <string>          : Watermark text on printed document
    -wtext does support following dynamic values:
    %PageCount%, %PageNumber%, %PageCountRoman%, %PageCountRoman2%,
    %PageNumberRoman%, %PageNumberRoman2%, %Author%, %Keywords%,
    %Subject%, %Title%, %Filename%, %Date%, %Time%
  -wtype <int>             : type of watermark
    0 : normal watermark
    1 : watermark on header
    2 : watermark on footer
  -wf <string>             : font name of watermark
  -wh <int>                : font size of watermark
  -wb                      : specify bold font
  -wi                      : specify an italic font
  -wu                      : specify an underlined font
  -ws                      : specify a strikeout font
  -wa <int>                : angle of watermark
  -wbox <string>           : a rectangle to output formatted text, it is only useful for "-walign" option, eg:
    -wbox "0,0,595,842"
    -wbox "0,0,612,792"
    -wbox "auto"
  -walign <int>            : set text align
    1 : left
    2 : center
    3 : right
  -wc <string>             : color of watermark,
    FF0000: Red color
    00FF00: Green color
    0000FF: Blue color
    HexNum: Other colors
  -wx <int>                : X offset of watermark
  -wy <int>                : Y offset of watermark
  -wpagebegin <int>        : first page to add the watermark
  -wpageend <int>          : last page to add the watermark
  -wpageoffset <int>       : a value to be added to page number
  -watermarkfile <string>  : a .ini file which contain information for multiple watermarks
  -svgnoclip               : remove clipping during SVG output
  -log <string>            : output log into a file
  -debug                   : Print log message on screen
  -runasuser <string>      : Run current EXE application from a user account
  -runaspwd <string>       : Password of specified user account
  -v                       : Print copyright and version info
  -h                       : Print usage information
  -help                    : Print usage information
  –help                   : Print usage information
  -?                       : Print usage information
  -$ <string>              : Input registration key
Example:

   doc2any.exe C:\in.doc C:\out.pdf
   doc2any.exe C:\in.ppt C:\out.pdf
   doc2any.exe C:\in.xls C:\out.pdf
   doc2any.exe C:\in.docx C:\out.pdf
   doc2any.exe C:\in.pptx C:\out.pdf
   doc2any.exe C:\in.xlsx C:\out.pdf
   doc2any.exe C:\*.doc C:\*.pdf
   doc2any.exe -margin 100x100x100x100 C:\in.rtf C:\out.pdf
   doc2any.exe -append 2 -width 612 -height 792 C:\*.doc C:\out.pdf
   doc2any.exe -append 2 C:\*.doc C:\out.pdf
   doc2any.exe -width 612 -height 792 C:\in.doc C:\out.pdf
   doc2any.exe -append 1 C:\in.doc C:\out.pdf
   doc2any.exe -append 2 C:\in.doc C:\out.pdf
   doc2any.exe -subject "subject" C:\in.doc C:\out.pdf
   doc2any.exe -ownerpwd 123 -keylen 2 -encryption 3900 C:\in.doc C:\out.pdf
   doc2any.exe "C:\in.doc" C:\out.gif
   doc2any.exe "C:\in.doc" C:\out.png
   doc2any.exe -useprinter -xres 300 -yres 300 -bitcount 1 -compression 4 "C:\in.doc" "C:\out.tif"
   doc2any.exe -useoffice 1 -useprinter -showofficeui "C:\in.doc" "C:\out.pdf"
   doc2any.exe -useprinter -useoffice 1 -showofficeui -delay 10000 -resetofficeview -debug "C:\in.doc" "C:\out.pdf"
   doc2any.exe -useoffice 1 -useprinter -delay 5000 "C:\in.doc" "C:\out.pdf"
   doc2any.exe -killoffice 0 -useprinter "C:\in.doc" C:\out.pdf
   doc2any.exe -multipagetif -killoffice 0 -useprinter "C:\in.doc" C:\out.tif
   doc2any.exe -multipagetif -bitcount 1 -xres 300 -yres 300 -killoffice 0 -useprinter "C:\in.doc" C:\out.tif
   doc2any.exe -useprinter -compression 88880 "C:\in.doc" C:\out.tif
   doc2any.exe -useprinter -compression 88881 "C:\in.doc" C:\out.tif
   doc2any.exe -useprinter -compression 88883 "C:\in.doc" C:\out.tif
   doc2any.exe -multipagetif -useprinter -compression 88880 "C:\in.doc" C:\out.tif
   for %F in (D:\test\*.doc) do "doc2any.exe" "%F" "%~dpnF.pdf"
   for /r D:\test %F in (*.doc) do "doc2any.exe" "%F" "%~dpnF.pdf"
   doc2any.exe -useprinter -useoffice 1 -noretry -password 123456 D:\test.docx D:\out.pdf
   doc2any.exe -viewerzoom 1600 -viewpage 10 -viewpagemode 2 -view "C:\in.doc" C:\out.pdf
   doc2any.exe -useprinter "C:\example.odt" "C:\openofficedoc.pdf"
   doc2any.exe "C:\example.odt" "C:\openofficedoc.pdf"
   doc2any.exe -installprinter -printername myprinter1 -printername2 myprinter2

Add watermarks into PDF files:

  

doc2any.exe -wtext "VeryPDF" "C:\in.doc" C:\out.pdf
   doc2any.exe -wtext "VeryPDF" -wc "0000FF" "C:\in.doc" C:\out.pdf
   doc2any.exe -wtext "VeryPDF" -wx 100 -wy 100 "C:\in.doc" C:\out.pdf
   doc2any.exe -wtext "VeryPDF" -wtype 1 "C:\in.doc" C:\out.pdf
   doc2any.exe -wtext "VeryPDF" -wtype 2 "C:\in.doc" C:\out.pdf
   doc2any.exe -wtext "VeryPDF" -wtype 0 -wa 45 "C:\in.doc" C:\out.pdf
   doc2any.exe -wtext "VeryPDF" -wf "Arial" "C:\in.doc" C:\out.pdf
   doc2any.exe -wtext "VeryPDF" -wf "Arial" -wh 20 "C:\in.doc" C:\out.pdf
   doc2any.exe -wtext "VeryPDF" -wf "Arial" -wh 20 -wb -wi -wu -ws "C:\in.doc" C:\out.pdf
   doc2any.exe -wtext "VeryPDF" -wf "Arial" -walign 3 -wh 20 -wbox "0,770,612,792" "C:\in.doc" C:\out.pdf
   doc2any.exe -wtext "Watermark %PageNumber% of %PageCount%" "C:\in.doc" C:\out.pdf
   doc2any.exe -wtext "Watermark %PageNumber% of %PageCount%" -wpagebegin 10 -wpageend 20 -wpageoffset 100 "C:\in.doc" C:\out.pdf
   doc2any.exe -wtext "Watermark %PageNumberRoman% of %PageCountRoman%" "C:\in.doc" C:\out.pdf
   doc2any.exe -wtext "Watermark %PageNumberRoman2% of %PageCountRoman2%" "C:\in.doc" C:\out.pdf
   doc2any.exe -wtext "Watermark %PageNumber% of %PageCount%" -walign 3 -wtype 1 "C:\in.doc" C:\out.pdf
   doc2any.exe -wtext "Watermark %PageNumber% of %PageCount%" -walign 2 -wtype 2 "C:\in.doc" C:\out.pdf
   doc2any.exe -wtext "%Filename% %Date% %Time% %PageNumber% of %PageCount%" "C:\in.doc" C:\out.pdf

下面是为原文件每个页面生成一个SWF文件。

You can add "%" to output filename, then you can create a SWF file for each page, for example,

doc2any.exe "C:\test.doc" "C:\out%.swf"
doc2any.exe "C:\test.ppt" "C:\slide%.swf"

PowerShell书籍收藏

1、PowerShell两本电子书籍

2、Professional Windows powershell Programming

image

http://www.bonashen.com/wp-content/uploads/2010/09/ProfessionalWindowsPowerShellProgramming.pdf

3、Windows powershell Cookbook,2nd

image

http://www.bonashen.com/wp-content/uploads/2010/09/Windows_PowerShell_Cookbook,2nd.pdf

4、Effective Windows PowerShell

image

http://www.bonashen.com/wp-content/uploads/2010/09/EffectiveWindowsPowerShell.pdf

PowerShell两本电子书籍

powershell刚开始学,先前网购了一本电子工业出版社出版的《Windows powershell 2.0 应用编程最佳实践》。

后来在网上找到两本PowerShell的电子书

1.Windows PowerShell Cookbook™

image

http://www.bonashen.com/wp-content/uploads/2010/09/OReilly.Windows.PowerShell.Cookbook.Oct.2007.pdf

2.Windows PowerShell in Action

image

http://www.bonashen.com/wp-content/uploads/2010/09/Manning.Windows.PowerShell.in.Action.Feb.2007.pdf

PowerShell 文件目录监视片段

摘自《Windows PowerShell 2.0应用编程最佳实践》

#pseventing 1.1
#filesystemwatcher
Add-PSSnapin pseventing 

$fsw = New-Object system.IO.FileSystemWatcher
$fsw.Path = [IO.Path]::GetTempPath()
$fsw.EnableRaisingEvents = $true 

Start-KeyHandler -CaptureCtrlC 

Connect-Event fsw changed,deleted -Verbose 

"watching $($fsw.path)"
"entering loop ... ctrl+C to exit"
$done = $false
while($events = @(Read-Event -Wait)){
   #read-event alays returns a cllection
   foreach($event in $events){
      switch($event.name){
          "ctrlc"{
            "cancelling..."
            $done = $true
            }
        "changed"{
            $event
            #$done = $true
        }
        "deleted"{
            $event
        }
      }
    }
    if($done -eq $true){
        break
    }
}    
调试结果如下图:
image 

delphi下的FileSystemWatcher,实现文件目录监控

{*******************************************************}
{                                                       }
{       FileSystemWatcher                               }
{                                                       }
{       版权所有 (C) 2007 solokey                       }
{                                                       }
{       http://blog.csdn.net/solokey                    }
{                                                       }
{*******************************************************}

unit FileSystemWatcher;

interface
uses
  Windows, Classes, SysUtils;

type
  TFileOperation = (foAdded, foRemoved, foModified, foRenamed);
  TFileDealMethod = procedure(FileOperation: TFileOperation; const FileName1,FileName2: string) of object;

  TNotifyFilter = (nfFileNameChange, nfDirNameChange, nfAttributeChange,
    nfSizeChange, nfWriteChange, nfAccessChange, nfCreationDateChange, nfSecurityChange);
  TNotifyFilters = set of TNotifyFilter;

  TNotificationBuffer =  array[0..4095] of Byte;

  PFileNotifyInformation = ^TFileNotifyInformation;
  TFileNotifyInformation = record
    NextEntryOffset: DWORD;
    Action: DWORD;
    FileNameLength: DWORD;
    FileName: array[0..0] of WideChar;
  end;

  TShellChangeThread = class(TThread)
  private
    FActived: Boolean;
    FDirectoryHandle: Cardinal;
    FCS: TRTLCriticalSection;
    FChangeEvent: TFileDealMethod;
    FDirectory: string;
    FWatchSubTree: Boolean;
    FCompletionPort: Cardinal;
    FOverlapped: TOverlapped;
    FNotifyOptionFlags: DWORD;
    FBytesWritten: DWORD;
    FNotificationBuffer: TNotificationBuffer;
  protected
    procedure Execute; override;
    procedure DoIOCompletionEvent;
    function ResetReadDirctory: Boolean;
    procedure Lock;
    procedure Unlock;
  public
    constructor Create(ChangeEvent: TFileDealMethod); virtual;
    destructor Destroy; override;
    procedure SetDirectoryOptions(Directory : String; Actived: Boolean; WatchSubTree : Boolean;
      NotifyOptionFlags : DWORD);
    property ChangeEvent : TFileDealMethod read FChangeEvent write FChangeEvent;
  end;

  TFileSystemWatcher = class(TComponent)
  private
    FActived: Boolean;
    FWatchedDir: string;
    FThread: TShellChangeThread;
    FOnChange: TFileDealMethod;
    FWatchSubTree: Boolean;
    FFilters: TNotifyFilters;
    procedure SetWatchedDir(const Value: string);
    procedure SetWatchSubTree(const Value: Boolean);
    procedure SetOnChange(const Value: TFileDealMethod);
    procedure SetFilters(const Value: TNotifyFilters);
    function  NotifyOptionFlags: DWORD;
    procedure SetActived(const Value: Boolean);
  protected
    procedure Change;
    procedure Start;
    procedure Stop;
  public
    constructor Create(AOwner : TComponent); override;
    destructor  Destroy; override;
  published
    property  Actived:Boolean  read FActived write SetActived;
    property  WatchedDir: string read FWatchedDir write SetWatchedDir;
    property  WatchSubTree: Boolean read FWatchSubTree write SetWatchSubTree;
    property  NotifyFilters: TNotifyFilters read FFilters write SetFilters;
    property  OnChange: TFileDealMethod read FOnChange write SetOnChange;
  end;

procedure  Register;

implementation

procedure  Register;
begin
  RegisterComponents('Samples', [TFileSystemWatcher]);
end;

{ TShellChangeThread }

constructor TShellChangeThread.Create(ChangeEvent: TFileDealMethod);
begin
  FreeOnTerminate := True;
  FChangeEvent := ChangeEvent;
  InitializeCriticalSection(FCS);
  FDirectoryHandle := 0;
  FCompletionPort := 0;
  inherited Create(True);
end;

destructor TShellChangeThread.Destroy;
begin
  CloseHandle(FDirectoryHandle);
  CloseHandle(FCompletionPort);
  DeleteCriticalSection(FCS);
  inherited Destroy;
end;

procedure TShellChangeThread.DoIOCompletionEvent;
var
  TempBuffer: TNotificationBuffer;
  FileOpNotification: PFileNotifyInformation;
  Offset: Longint;
  FileName1, FileName2: string;
  FileOperation: TFileOperation;
  procedure DoDirChangeEvent;
  begin
    if Assigned(ChangeEvent) and FActived then
      ChangeEvent(FileOperation, FileName1, FileName2);
  end;
  function  CompleteFileName(const FileName:string):string;
  begin
    Result := '';
    if Trim(FileName) <> '' then
      Result := FDirectory + Trim(FileName);
  end;
begin
  Lock;
  TempBuffer := FNotificationBuffer;
  FillChar(FNotificationBuffer, SizeOf(FNotificationBuffer), 0);
  Unlock;
  Pointer(FileOpNotification) := @TempBuffer[0];
  repeat
    with FileOpNotification^ do begin
      Offset := NextEntryOffset;
      FileName2 := '';
      case Action of
        FILE_ACTION_ADDED..FILE_ACTION_MODIFIED: begin
          FileName1 := CompleteFileName(WideCharToString(FileName));
          FileOperation := TFileOperation(Action - 1);
          DoDirChangeEvent;
        end;
        FILE_ACTION_RENAMED_OLD_NAME: begin
          FileName1 := CompleteFileName(WideCharToString(FileName));
          FileOperation := TFileOperation(Action - 1);
        end;
        FILE_ACTION_RENAMED_NEW_NAME: begin
          if FileOperation = foRenamed then begin
            FileName2 := CompleteFileName(WideCharToString(FileName));
            DoDirChangeEvent;
          end;
        end;
      end;
    end;
  Pointer(FileOpNotification) := Pointer(PChar(FileOpNotification) + OffSet);
  until Offset=0;
end;

procedure TShellChangeThread.Execute;
var
  numBytes: DWORD;
  CompletionKey: DWORD;
  PFOverlapped: POverlapped;
  TempDirectoryHandle: Cardinal;
  TempCompletionPort: Cardinal ;
begin

  while not Terminated do begin
    Lock;
    TempDirectoryHandle := FDirectoryHandle;
    TempCompletionPort := FCompletionPort;
    Unlock;
    if TempDirectoryHandle > 0  then begin
      PFOverlapped := @FOverlapped;
      GetQueuedCompletionStatus(TempCompletionPort, numBytes, CompletionKey, PFOverlapped, INFINITE);
      if CompletionKey = Handle then begin
        Synchronize(DoIOCompletionEvent);
        FBytesWritten := 0;
        FillChar(FNotificationBuffer, SizeOf(FNotificationBuffer), 0);
        ReadDirectoryChanges(FDirectoryHandle, @FNotificationBuffer, SizeOf(FNotificationBuffer), FWatchSubTree, FNotifyOptionFlags, @FBytesWritten, @FOverlapped, nil);
      end;
    end;
  end;
  PostQueuedCompletionStatus(TempCompletionPort, 0, 0, nil);
end;

procedure TShellChangeThread.Lock;
begin
  EnterCriticalSection(FCS);
end;

function TShellChangeThread.ResetReadDirctory: Boolean;
var
  TempHandle: Cardinal;
  TempCompletionPort: Cardinal;
begin
  Result := False;
  CloseHandle(FDirectoryHandle);
  PostQueuedCompletionStatus(FCompletionPort, 0, 0, nil);
  CloseHandle(FCompletionPort);

  TempHandle := CreateFile(PChar(FDirectory), GENERIC_READ or GENERIC_WRITE,
                            FILE_SHARE_READ or FILE_SHARE_WRITE or FILE_SHARE_DELETE,
                            nil, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS or FILE_FLAG_OVERLAPPED, 0);
  Lock;
  FDirectoryHandle := TempHandle;
  Unlock;

  if (GetLastError = ERROR_FILE_NOT_FOUND) or (GetLastError = ERROR_PATH_NOT_FOUND) then begin
    Lock;
    FDirectoryHandle := 0;
    FCompletionPort := 0;
    Unlock;
    Exit;
  end;

  TempCompletionPort := CreateIoCompletionPort(FDirectoryHandle, 0, Handle, 0);

  Lock;
  FCompletionPort := TempCompletionPort;
  Unlock;

  FBytesWritten := 0;
  FillChar(FNotificationBuffer, SizeOf(FNotificationBuffer), 0);
  Result := ReadDirectoryChanges(FDirectoryHandle, @FNotificationBuffer, SizeOf(FNotificationBuffer), FWatchSubTree, FNotifyOptionFlags, @FBytesWritten, @FOverlapped, nil);
end;

procedure TShellChangeThread.SetDirectoryOptions(Directory: String; Actived: Boolean;
  WatchSubTree: Boolean;  NotifyOptionFlags : DWORD);
begin
  FWatchSubTree := WatchSubTree;
  FNotifyOptionFlags := NotifyOptionFlags;
  FDirectory := IncludeTrailingBackslash(Directory);
  FActived := Actived;
  ResetReadDirctory;
end;

procedure TShellChangeThread.Unlock;
begin
  LeaveCriticalSection(FCS);
end;

{ TFileSystemWatcher }

procedure TFileSystemWatcher.Change;
begin
  if csDesigning in ComponentState then
    Exit;
  if Assigned(FThread) then begin
    FThread.SetDirectoryOptions(FWatchedDir, FActived, LongBool(FWatchSubTree), NotifyOptionFlags);
  end;
end;

constructor TFileSystemWatcher.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FActived := False;
  FWatchedDir := 'C:\';
  FFilters := [nfFilenameChange, nfDirNameChange];
  FWatchSubTree := True;
  FOnChange := nil;
end;

destructor TFileSystemWatcher.Destroy;
begin
  if Assigned(FThread) then
    FThread.Terminate;
  inherited Destroy;
end;

function TFileSystemWatcher.NotifyOptionFlags: DWORD;
begin
  Result := 0;
  if nfFileNameChange in FFilters then
    Result := Result or FILE_NOTIFY_CHANGE_FILE_NAME;
  if nfDirNameChange in FFilters then
    Result := Result or FILE_NOTIFY_CHANGE_DIR_NAME;
  if nfSizeChange in FFilters then
    Result := Result or FILE_NOTIFY_CHANGE_SIZE;
  if nfAttributeChange in FFilters then
    Result := Result or FILE_NOTIFY_CHANGE_ATTRIBUTES;
  if nfWriteChange in FFilters then
    Result := Result or FILE_NOTIFY_CHANGE_LAST_WRITE;
  if nfAccessChange in FFilters then
    Result := Result or FILE_NOTIFY_CHANGE_LAST_ACCESS;
  if nfCreationDateChange in FFilters then
    Result := Result or FILE_NOTIFY_CHANGE_CREATION;
  if nfSecurityChange in FFilters then
    Result := Result or FILE_NOTIFY_CHANGE_SECURITY;
end;

procedure TFileSystemWatcher.SetActived(const Value: Boolean);
begin
  if FActived <> Value then begin
    FActived := Value;
    Change;
    if FActived then
      Start
    else
      Stop;
  end;
end;

procedure TFileSystemWatcher.SetFilters(const Value: TNotifyFilters);
begin
  if FFilters <> Value then begin
    FFilters := Value;
    Change;
  end;
end;

procedure TFileSystemWatcher.SetOnChange(const Value: TFileDealMethod);
begin
  FOnChange := Value;
  if Assigned(FOnChange) and FActived then
    Start
  else
    Stop;
  Change;
end;

procedure TFileSystemWatcher.SetWatchedDir(const Value: string);
begin
  if not SameText(FWatchedDir, Value) then begin
    FWatchedDir := Value;
    Change;
  end;
end;

procedure TFileSystemWatcher.SetWatchSubTree(const Value: Boolean);
begin
  if FWatchSubTree <> Value then begin
    FWatchSubTree := Value;
    Change;
  end;
end;

procedure TFileSystemWatcher.Start;
begin
  if csDesigning in ComponentState then
    Exit;
  if Assigned(FOnChange) then begin
    FThread := TShellChangeThread.Create(FOnChange);
    FThread.SetDirectoryOptions(FWatchedDir, FActived, LongBool(FWatchSubTree), NotifyOptionFlags);
    FThread.Resume;
  end;
end;

procedure TFileSystemWatcher.Stop;
begin
  if csDesigning in ComponentState then
    Exit;
  if Assigned(FThread) then begin
    FThread.Terminate;
    FThread := nil;
  end;
end;

end.

脱壳UPX 0.89.6 – 1.02 / 1.05 – 1.24 -> Markus & Laszlo

最近看到verydoc的一套命令行转换工具,其中有一款PDF to vec(PDF文件转矢量文件),用PEiD查看是UPX 0.89.6 – 1.02 / 1.05 – 1.24 -> Markus & Laszlo壳,准备脱了他。

工具:

PEid

LoadPE

WinHex

UPX 2.03w

参照http://teach.hanzify.org/article/15-1060099200.html

第一步    PEid检测壳结果如下图

image

第二步  修改数据段

启动LoadPE工具,加载pdf2vec.exe,Sections,修改第一、第二段的名称分别为UPX0、UPX1保存。

image

第三步 修改UPX的解压版本

启动WinHex工具,打开第二步修改后的文件,移动数据区到03E0位置。如下图:

image

当前的版本是2.00,我们用UPX的高版来解压他,修改UPX的版本为2.03w。

image

保存修改的文件。

继续阅读

关于船厂技术发展的路线思考

从各大厂应用tribon系统发展来看,其技术设计人员是一个倒金字塔结构。其中线型光顺、外板展开、曲面建模是塔尖,形成船体的主要领导力量,工艺人员、设计管理人员、图纸标准制定人员是塔腰,平面建模、零件建模、出图是塔基。如下图:

clip_image002

鉴于国内某造船大厂的技术发展路线,我们可以看出其技术设计发展以tribon系统的应用为切入点,走消化吸收、自我完善、自主创新、技术扩张的道路。

  1. 其中消化吸收是打基础,多采取联合设计,尽可能让联合设计队伍驻厂开展设计工作,这样可以更多的消化吸收其设计技能、设计管理技能。
  2. 自我完善是夯实基础,以工艺标准化为切入点,对设计工作的标准化,每位设计人员的工作范围、工作目标、工作标准进行固化,从而有利于技术设计管理、技术工艺的管理。将生产设计转向工艺设计,将零件制图转向装配制图,从而降低生产现场施工的难度。
  3. 自主创新是工艺创新,在自我完善的基础上方有能力应对工艺创新,让技术设计人员更多的关注工艺创新,来领导现场工艺的变革,提高现场施工质量与效率,从而降低生产成本。
  4. 技术扩张是指核心技术(技术管理模式、技术工艺标准、技术图纸标准固化、具有线型光顺及曲面建模能力)稳定的基础上,大量外包金字塔的塔基工作量,降低技术设计成本,提高技术设计的效率,使船厂的技术设计能力得到量变,能够在短时间内高质量完成某型船的生产设计,从而具有快速影响市场的应变能力。