星期五, 十一月 20, 2009

wxwidgets convet wxString to C Style char

wxString 提供的 c_str,fn_str,char_str等都source code encoding相关

如果想转换成功,必须注意编译的encoding选择。

比如如果打开了unicode的编译选择,wxWidgets想从一个wxString得到一个 c Style的char *
最安全的方法为:
wxString asc=wxString("this is 汉字");
char *=asc.mb_str(wxConvUTF8);

curl 如何在mingw下使用


首先从http://curl.haxx.se/下载最新的源代码包。
比如 curl-7.19.7.tar.gz
1.然后将其展开到一个目录下,将来将要引用这里面的内容,include和lib
2.进入lib目录下:运行 mingw32-make -f Makefile.m32 编译生成所有的库.libcur.a及libcurl.dll等
3.进入/curl/docs/examples/ 编译个测试程序:
gcc -DCURL_STATICLIB -I ../../include -L ../../lib simple.c -o simple -lcurl -lws2_32 -lwinmm

运行simple.exe,能够正常运行。
CodeBlocks 里如何使用libcurl 实现static link(静态连接,避免运行使用libcurl.dll)

在codeblocks里可以在项目属性build options link setting 里加入 libcur.a的包,以及定义编译使用静态链接的属性
CURL_STATICLIB或者在使用的代码里加入:

#define CURL_STATICLIB

codeblock配置如图:


注意:如果编译的时候出现符号错误:
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_set_optionA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_initA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_set_optionA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_simple_bind_sA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_search_sA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_first_entry'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_get_dnA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_first_attributeA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_get_values_lenA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_value_free_len'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_memfreeA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_next_attributeA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_memfreeA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_next_entry'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_err2stringA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_unbind_s'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_msgfree'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_err2stringA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_set_optionA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_simple_bind_sA'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ber_free'
curl-7.19.7\lib\libcurl.a(ldap.o) undefined reference to `_imp__ldap_err2stringA'

这是需要连接mingw32的 ldap32 .这个需要在项目的build option link lib 里加入:
D:\MinGW\lib\libwldap32.a,顺序要注意.

libwldap32.a必须在libcurl.a的后面

星期一, 十一月 16, 2009

Windows rundll32 utility

Any program using the Windows file association mechanism can be started with the rundll32 utility.

用一个编辑器,打开一个默认后缀的文件:

RUNDLL32.EXE SHELL32.DLL,OpenAs_RunDLL c:\temp\a.txt

ere a list of what is available
rundll32 shell32,Control_RunDLL                     Run The Control Panel
rundll32 shell32,Control_RunDLL X Start applet X of Control Panel
("X" = any CPL filename)
rundll32.exe shell32.dll,Control_RunDLL intl.cpl,,4 Regional setting, Date tab

rundll32 shell32,OpenAs_RunDLL \dir\filename.txt Open The 'Open With...' Window
rundll32 shell32,ShellAboutA Info-Box Open 'About Window Window'
rundll32 shell32,Control_RunDLL desk.cpl Open Display Properties
rundll32 user,cascadechildwindows Cascade All Windows
rundll32 user,tilechildwindows Minimize All Child-Windows
rundll32 user,repaintscreen Refresh Desktop
rundll32 keyboard,disable Lock The Keyboard
rundll32 mouse,disable Disable Mouse
rundll32 user,swapmousebutton Swap Mouse Buttons
rundll32 user,setcursorpos Set Cursor Position To (0,0)
rundll32 user,wnetconnectdialog Show 'Map Network Drive' Window
rundll32 user,wnetdisconnectdialog Show 'Disconnect Network Disk' Window
rundll32 user,disableoemlayer Display The BSOD (blue screen of death)Window
rundll32 diskcopy,DiskCopyRunDll Show Copy Disk Window
rundll32 rnaui.dll,RnaWizard Run 'Internet Connection Wizard'
rundll32 shell32,SHFormatDrive Run 'Format Disk (A)' Window
rundll32 shell32,SHExitWindowsEx -1 Cold Restart Of Windows Explorer
rundll32 shell32,SHExitWindowsEx 1 Shut Down Computer
rundll32 shell32,SHExitWindowsEx 0 Logoff Current User
rundll32 shell32,SHExitWindowsEx 2 Windows9x Quick Reboot
rundll32 krnl386.exe,exitkernel Force Windows 9x To Exit (no confirmation)
rundll32 rnaui.dll,RnaDial "MyConnect" Run 'Net Connection' Dialog
rundll32 msprint2.dll,RUNDLL_PrintTestPage Choose & Print Test Page Of Current Printer
rundll32 user,setcaretblinktime Set New Cursor Rate Speed
rundll32 user, setdoubleclicktime Set New DblClick Speed (Rate)
rundll32 sysdm.cpl,InstallDevice_Rundll Hardware installation wizard
rundll32 user,MessageBeep Default beep sound
rundll32 user32.dll,MessageBeep Default beep sound (XP)
rundll32 shell32.dll,Control_RunDLL appwiz.cpl Add/remove programs
rundll32 shell32.dll,Control_RunDLL timedate.cpl,,0 Date/time settings
rundll32 shell32.dll,Control_RunDLL odbccp32.cpl ODBC settings

rundll32.exe url.dll,FileProtocolHandler http:\\www.rgagnon.com
rundll32.exe url.dll,FileProtocolHandler c:\mypdf.pdf
Open the associated application
rundll32 amovie.ocx,RunDll /play /close c:\mymovie.mpg
Play multimedia (movie or sound)

Rundll32.exe powrprof.dll,SetSuspendState Sleep Put the computer in Sleep mode


Privacy (IE)
rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 8 Internet temporary files
rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 2 Cookies
rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 1 History
rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 16 Forms Data
rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 32 Passwords
rundll32.exe InetCpl.cpl,ClearMyTracksByProcess 255 Delete everything

星期二, 十一月 03, 2009

mysql get table index SQL command

1.show index from tablename
2.select * from information_schema.statistics where table_name='tableName' ;

星期一, 十一月 02, 2009

Mysql 性能分析


EXPLAIN
SELECT * FROM table IGNORE INDEX (indexname) WHERE