30 Haziran 2019 Pazar

Shell Extension

Shell Extension Nedir ?
Açıklaması şöyle.
A shell extension is a COM object that adds some kind of functionality to the Windows shell (Explorer).

There are two parts in the term "shell extension." Shell refers to Explorer, and extension refers to code you write that gets run by Explorer when a predetermined event happens (e.g., a right-click on a .DOC file). So a shell extension is a COM object that adds features to Explorer.

A shell extension is an in-process server that implements some interfaces that handle the communication with Explorer.

There are many types of shell extensions, each type being invoked when different events happen.
Bazı tipler şöyle.
Context Menu Handler - Dosyay sağ tıklayınca
Property Sheet Handler - Properties penceresi açılınca
Drag and Drop Handler - Sağ tıklama sürek bırak yapınca
Drop Handler - Dosyaya sürükle bırak yapınca
QueryInfo Handler - Fare bir nesne üzerinde yüzerse





27 Haziran 2019 Perşembe

CreateEvent metodu

Örnek
Şöyle yaparız.
OVERLAPPED osWriteS = { 0 };
osWriteS.Offset = 0;
osWriteS.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);

18 Haziran 2019 Salı

GetSystemTimePreciseAsFileTime metodu

Giriş
Açıklaması şöyle.
In Windows 8+, there is a GetSystemTimePreciseAsFileTime function which offers the high resolution of QueryPerformanceCounter combined with the accuracy of the system time.

QueryPerformanceCounter metodu

Giriş
Şu satırı dahil ederiz.
#include <windows.h>
Açıklaması şöyle. Sistem saatinden bağımsızdır. Java'daki System.nano() ile aynıdır.
When you need time stamps with a resolution of 1 microsecond or better and you don't need the time stamps to be synchronized to an external time reference, choose QueryPerformanceCounter.
Windows 8
Açıklaması şöyle. TSC kısaltması Time Stamp Counter anlamına gelir. 64 bitlik bir register olarak düşünülebilir. HPET kısaltması High Precision Event Timer anlamına gelir.
QueryPerformanceCounter was always based on a TSC (as oppose to Windows 7, where it could be a TSC, HPET or the ACPI PM timer - the latter of which is especially rather inaccurate.)
Örnek - Saniye Süre Ölçme
Şöyle yaparız
LARGE_INTEGER frequency;
QueryPerformanceFrequency(&frequency);

LARGE_INTEGER start;
LARGE_INTEGER end;
QueryPerformanceCounter(&start);
...
QueryPerformanceCounter(end); 

double interval = (double) (end.QuadPart - start.QuadPart) / (frequency.QuadPart / 1000);
printf("%f ms\n", interval)
Örnek - Mikro saniye Süre Ölçme
Şöyle yaparız
long long unsigned int GetCurrentTimestamp()
{
   LARGE_INTEGER res;
   QueryPerformanceCounter(&res);
   return res.QuadPart;
}


long long unsigned int initalizeFrequency()
{
   LARGE_INTEGER res;
   QueryPerformanceFrequency(&res);
   return res.QuadPart;
}


//start time stamp

long long unsigned int start = GetCurrentTimestamp();

// ....
// execution that should be measured
// ....

std::cout << "Processing time is " << ((end - start) * 1000000 / initalizeFrequency()) 
            << " microsec "<< std::endl;
Sonuç olarak şunu alırız
Processing time is 24 microsec
Örnek
Şöyle yaparız.
SystemTime getSystemTime()
{
  LARGE_INTEGER t;
  
  if (!QueryPerformanceCounter(&t)) {
    return static_cast<SystemTime>(-1);
  }
  return static_cast<SystemTime>(t.QuadPart);
}
Örnek
Java kodu şöyle.
LARGE_INTEGER current_count;
QueryPerformanceCounter(&current_count);
double current = as_long(current_count);
double freq = performance_frequency;
jlong time = (jlong)((current/freq) * NANOSECS_PER_SEC);
return time;

13 Haziran 2019 Perşembe

SetTextColor

Örnek
Şöyle yaparız.
HDC hdcStatic = ...
SetTextColor(hdcStatic, RGB(0, 0, 0));