星期二, 9月 08, 2009

postgresql 對應 mysql

For those coming from MySQL:
SHOW TABLES = \d
SHOW DATABASES = \l
SHOW COLUMNS = \d table

However the \* commands only work in psql and not via other interfaces, such as queries via PHP. Similar data can be retrieved with the following SQL commands:

SHOW TABLES (\d) = SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'

SHOW DATABASES (\l) = SELECT datname FROM pg_database;

SHOW COLUMNS FROM table (\d table) = SELECT column_name FROM information_schema.columns WHERE table_name ='table';

To get the column names in their "natural" order (as in, the order they were created), use:
SELECT column_name FROM information_schema.columns WHERE table_name ='< table >' ORDER BY ordinal_position;


Alternatively you could send psql metacommands to psql directly:

SHOW TABLES -> echo "\d" | psql "database"

Use "psql -tA" for script friendly format.

星期四, 4月 02, 2009

抓mmmmacaddress

IP_ADAPTER_INFO AdapterInfo[16]; // Allocate information
DWORD dwBufLen = sizeof(AdapterInfo); // Save memory size of buffer
DWORD dwStatus = GetAdaptersInfo( AdapterInfo, &dwBufLen);
PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo; // Contains pointer to
do {
if(strcmp(pAdapterInfo->IpAddressList.IpAddress.String,"0.0.0.0")!=0)
{
int a=0;
}
pAdapterInfo = pAdapterInfo->Next; // Progress through
// linked list
}
while(pAdapterInfo); // Terminate if last adapter

星期四, 3月 26, 2009

在Release 產生 code dump on windows

在Linux 上寫程式時很方便的會使用gdb 然後配合一下 core檔來Deubg,windows也是該有才對。
MSDN上也有說名
首先打開專案資料夾
屬性選項
c/c++
啟用c/c++ 例外狀況
我選了 是,但有 SEH 例外狀況 (/EHa)



再配合MiniDumper catch dump之後
HMODULE hDll = ::LoadLibrary( TEXT("DBGHELP.DLL") );
MiniDumpWriteDump

產生之後,用VS開起dmp 配合設定一下/(指定偵錯符號檔)就可以找出當的位置了。以前還在那邊算map-_-

星期一, 1月 12, 2009

Struct 小記

struct MsgStruct
{
int m_nprotocol;
int nSize;
char myData[0];
};

可變長度 只要把
myData 用隨意的記憶體蓋過就是長在MsgStruct之後隨之送出即可,比較要注意的是,加上的記憶體長度。