23 Mayıs 2020 Cumartesi

PIF Executable Format

Giriş
Açıklaması şöyle.
Real PIFs are indeed “only” configuration files, but they are executable: running a PIF will run the corresponding program, with the configuration specified by the PIF. This can be used as-is: a “real” PIF can be sent to a user, and if that user runs it, the commands specified in the PIF will be run; starting with VMM 4.0 (Windows 95), PIFs can even include CONFIG.SYS and AUTOEXEC.BAT instructions, so multiple commands can be chained.

21 Mayıs 2020 Perşembe

wcstombs_s metodu

Giriş
UTF16'dan Multi Byte Character Set'e çevirir. Açıklaması şöyle.
Multibyte character sets (MBCSs) are an older approach to the need to support character sets, like Japanese and Chinese, that cannot be represented in a single byte. If you are doing new development, you should use Unicode for all text strings except perhaps system strings that are not seen by end users. MBCS is a legacy technology and is not recommended for new development.

Örnek
Şöyle yaparız.
std::string UTF16_to_MBCS(LPCWSTR wsz)
{
  // MBCS to UNICODE
  std::string strResult;

  size_t nCharsDone = 0;
  const size_t nMaxWords = 2 * wcslen(wsz);

  strResult.resize(nMaxWords + 1);

  if (S_OK == ::wcstombs_s(&nCharsDone, &strResult[0], nMaxWords + 1, wsz, nMaxWords))
    strResult.resize(nCharsDone);
  else
    strResult.clear();
  return strResult;
}

mbstowcs_s metodu

Giriş
Multi Byte Character Set'ten UTF-16'ya çevirir. Multi Byte Character Set'e çevirir. Açıklaması şöyle.
Multibyte character sets (MBCSs) are an older approach to the need to support character sets, like Japanese and Chinese, that cannot be represented in a single byte. If you are doing new development, you should use Unicode for all text strings except perhaps system strings that are not seen by end users. MBCS is a legacy technology and is not recommended for new development.

Örnek
Şöyle yaparız.
#include <windows.h>
#include <string>

std::wstring MBCS_to_UTF16(LPCSTR sz)
{
  // MBCS to UNICODE
  std::wstring strResult;

  size_t nCharsDone = 0;
  const size_t nMaxsWords = 6 * strlen(sz);

  strResult.resize(nMaxsWords + 1);

  if (S_OK == ::mbstowcs_s(&nCharsDone, &strResult[0], nMaxsWords + 1, sz, nMaxsWords))
    strResult.resize(nCharsDone);
  else
    strResult.clear();
  return strResult;
}

14 Mayıs 2020 Perşembe

Win32 API - Retrocomputing

Win32 API'si Windows NT ile başladı denilebilir. Açıklaması şöyle
Windows NT switched from an OS/2-based API to a new 32-bit API, Win32, based on the existing 16-bit Windows API

10 Mayıs 2020 Pazar

Autorun

Örnek
HKCU\Software\Microsoft\Command Processor\Autorun alanında komut tanımlanabilir.

4 Mayıs 2020 Pazartesi

Windows sc komutu - Servisleri Kontrol Eder

Giriş
sc komutuyla gerekirse uzaktaki bir sunucuya da bağlanabilir.

query seçeneği
Tüm servisleri sorgulamak için şöyle yaparız
sc.exe query


Component Object Model - COM

Giriş
COM kullanınca direkt DLL ile linklemek gerekmiyordu. Açıklaması şöyle. Ayrıca ilk başta COM dosyaları registry kullanılarak bulunuyordu.
In the early 1990s Microsoft introduced COM (Component Object Model) which was widely used in various programming environments include Visual Basic 5 & 6. Also known as ActiveX (at least if COM & ActiveX are not the same thing they are often conflated).

COM required adding information in the Windows registry so that a program would be able to find & use code packaged into a DLL. e.g., you write a class and compile it into a DLL. But your program wouldn't link directly with that DLL (as was typical beforehand), instead the DLL would be registered on the computer which meant: references to the DLL would be stored in the Windows registry with a unique ID. Later when a program wanted to use something from that DLL it would look in the registry for the ID and hopefully find the required DLL from there.
Daha sonra sadece registry ile çalışma yöntemi değiştirildi. Açıklaması şöyle.
Note -- later on, in Windows XP IIRC Microsoft provided an additional file-based mechanism to tie together a program and its COM DLL references that did not require the registry at all. So it apparently was not strictly necessary to use the registry-based approach.
COM Nesnesi Yaratmak
Açıklaması şöyle
... there are two ways to create COM objects:

- The module that implements the object might provide a function specifically designed to create instances of that object.
- Alternatively, COM provides a generic creation function named CoCreateInstance.