2012-12-11 2 views
2

메모장 + +에서 현재 열린 파일의 마지막 수정 날짜 및 시간을 표시 할 수 있습니까? 해당 정보를 항상 볼 수 있으면 좋을 것입니다. 상태 표시 줄에.메모장에서 파일 수정 날짜 표시 ++

Windows XP SP3에서 메모장 ++ v5.9.3 (유니 코드)을 사용하고 있습니다.

답변

1

C# Console app; 내가 5 분 만에 이것을 썼다. 왜냐하면 그것이 내가 가진 전부이기 때문이다. 꽤 좋지는 않지만 지금 할 수있는만큼 좋은 것입니다. 그것은 최소한 출발점입니다.

Notepad++ Last Date Modified

using System; 
using System.Collections.Generic; 
using System.Diagnostics; 
using System.IO; 
using System.Linq; 
using System.Runtime.InteropServices; 
using System.Text; 
using System.Threading; 
using System.Threading.Tasks; 
using System.Windows.Forms; 

namespace Notepadd___DateModified 
{ 
    class Program 
    { 
     [DllImport("user32.dll", SetLastError = true)] 
     static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow); 

     [DllImport("user32.dll", EntryPoint = "SendMessage", CharSet = System.Runtime.InteropServices.CharSet.Auto)] 
     public static extern bool SendMessage(IntPtr hWnd, uint Msg, int wParam, StringBuilder lParam); 

     [DllImport("user32.dll", SetLastError = true)] 
     public static extern IntPtr SendMessage(int hWnd, int Msg, int wparam, int lparam); 

     [DllImport("user32.dll")] 
     public static extern int SendMessage(IntPtr hWnd, int msg, int Param, string s); 

     const int WM_GETTEXT = 0x000D; 
     const int WM_SETTEXT = 0x000c; 
     const int WM_GETTEXTLENGTH = 0x000E; 

     static void Main(string[] args) 
     { 
      while (true) 
      { 

       foreach (Process p in Process.GetProcessesByName("Notepad++")) 
       { 
        if (p.Id != Process.GetCurrentProcess().Id) 
        { 
         try 
         { 
          DateTime LastModified = Directory.GetLastWriteTime(p.MainWindowTitle.Replace(" - Notepad++", "")); 

          IntPtr childHandle; 
          childHandle = FindWindowEx(p.MainWindowHandle, IntPtr.Zero, "msctls_statusbar32", null); 

          StringBuilder subtitle = new StringBuilder(); 
          Int32 subsize = SendMessage((int)childHandle, WM_GETTEXTLENGTH, 0, 0).ToInt32(); 

          if (subsize > 0) 
          { 
           subtitle = new StringBuilder(subsize + 1); 
           SendMessage(childHandle, (int)WM_GETTEXT, subtitle.Capacity, subtitle); 
          } 

          if (!subtitle.ToString().Contains(" - Last Modified: " + LastModified.ToString())) 
          { 
           SendMessage(childHandle, WM_SETTEXT, 0, subtitle.ToString().Split(new string[] { " - Last Modified: " },StringSplitOptions.None)[0] + " - Last Modified: " + LastModified.ToString()); 
           Console.Out.WriteLine(subtitle + " - Last Modified: " + LastModified.ToString()); 
          } 
         } 
         catch 
         { 
          break; 
         } 
        } 
        else return; 
       } 
       Thread.Sleep(1000); 
      } 
     } 
    } 
} 
+0

내가 이것을 어떻게 실행합니까? 어떤 플러그인이 필요합니까? – baruch

+0

그것은 C# 콘솔 응용 프로그램입니다. 윈도우를 실행하고 있다면 Visual Studio Express 또는 다른 컴파일러를 사용하여 새 윈도우를 만들 수 있습니다. 또는 컴파일러에서 만든 프로젝트를 사용할 수 있습니다. https://compilr.com/deusaphor/notepad-datemodified – DeusAphor

+0

참고 : 프로젝트를 마우스 오른쪽 버튼으로 클릭하고 "다운로드 바이너리"를 클릭해야합니다. 소스 코드가 포함되어있어 실행중인 코드를 정확히 알 수 있습니다. – DeusAphor