Sean's Note

2011年9月8日 星期四

char, wchar_t and TCHAR


在 c 裡常見的 char 代表 1 個 byte,

後來為了引入寬字元, 而有了 2 個 bytes 的 wchar_t,

wchar_t 的定義如下 :

typedef unsigned short wchar_t;

平常我們所用的字串處理函式如下 :

char* str = "hello!"; // 7

len = strlen(str);

當然也有用來處理寬字元字串的函式 :

wchar_t* str = "hello!"; // 14

len = wcslen(str);

為了使程式既能按 ASCII 又能按 Unicode 編譯,而衍伸了通用變數 TCHAR,

在 tchar.h 裡可以看到,當有 #define _UNIOCODE 時

typedef wchar_t TCHAR

反之,

typedef char TCHAR

如此一來,使用通用變數,將會使得程式碼更為一致性。

而通用的字串處理函式如 : l + 函式名稱

len = lstrlen(str);
len = lstrcpy(str);
len = lstrcpyn(str);
len = lstrcat(str);

2011年6月19日 星期日

k-lite mega code 播 rmvb 沒有聲音

今天在 win7 上裝了最新的 k-lite mega code 7.2.0,結果播 rmvb 檔卻沒有聲音,

於是在官網的 F.A.Q. 上看到


Q: RMVB files play without sound
A: You are probably missing a decoder for RealAudio COOK. You can install that by following these steps:

  1. Download the Windows version of binary codec pack for MPlayer.
    http://www.mplayerhq.hu/design7/dload.html#binary_codec
    (filename = windows-essential-20071007.zip)
  2. Extract only these files from the ZIP archive:
    cook.dllpncrt.dllsipr3260.dlldrv33260.dlldrv43260.dll
  3. Put those files in the Windows system folder.
    That is C:\Windows\System32\ on a 32-bit version of Windows.
    That is C:\Windows\SysWOW64\ on a 64-bit version of Windows.

照著做就搞定了!

2011年3月30日 星期三

[DM6437] Pin Mux 的設定

可去官網抓 DM643x  Pin Mux Utility.exe 來用。

[DM6437] FlashBurn

平常透過 USB 在板子上模擬都是寫在 RAM 上,所以電源一關掉,

程式也就被洗掉了。這時候就可以使用 FlashBurn,

在 dvsdk 資料夾下可以搜尋到 DM643x Flashing Instructions.pdf,

照著 PDF 的步驟下載 FlashBurn DSK,即可把程式燒進 Flash,

每次把 DSP 電源開啟時就會跑自己燒進去的程式。


記得要呼叫這行 EVMDM6437_init();

因為利用 CCS 開發,startup 和 evmdm6437bsl.lib 會自動幫我們

初始一些環境,所以要手動加入,如果沒加這行有些功能就無法 work,

像是 UART。

2011年3月15日 星期二

[C/C++] extern 的用法

想要宣告一全域變數讓其他文件 (.c 或 .cpp) 共同使用,

必須在型態前加上 extern, 表示變數在文件之外, 如 :

int data; // 宣告在 file1.c

extern int data; // 則必須宣告在 flie1.h

當 file2.c 要使用變數時, 只要 include file1.h 即可,

不必再宣告該變數.

2011年2月15日 星期二

[Windows] 桌面上出現奇怪的IE圖示無法刪除

到 regedit 裡搜尋 {e17d4fc0-5564-11d1-83f2-00a0c90dc849}


這組機碼是負責搜尋功能的,大陸人很愛改寫這些機碼,


來綁架網頁和使搜尋功能壞掉,只要把這些機碼刪除,在重新修復即可。


修復搜索.reg