金曜日, 7月 23, 2010

Win32 API: C++ to .NET

Win32 API: C++ to .NET





Data Types (C# vs. Java)

.NET Framework Developer's Guide: OutArrayOfStructs Sample

.NET Framework Developer's Guide OutArrayOfStructs Sample

PinvokeLib.dll

pinvoke.net: the interop wiki!


Calling Win32 DLLs in C# with P/Invoke

C# 411

C++で作成したDLLをデバッグで確認したい

C++で作成したDLLをデバッグで確認したい



ディレクトリ構成はこんな感じになっているべきです。

ソリューション ディレクトリ
├VC++ DLL プロジェクト ディレクトリ
|└ソースファイル、ヘッダファイル等
├Debug(VC++ DLL 出力ディレクトリ)
|└DLL、PDB(※)
└C# プロジェクト ディレクトリ
 ├ソースファイル
 └bin
  └Debug
   ├C# EXE
   └DLL、PDB(※からコピー)

日曜日, 7月 18, 2010

金曜日, 7月 16, 2010

How to use c++ to connect SQLServer?

How to use c++ to connect SQLServer?




SQLAPI++ is a C++ library for accessing multiple SQL databases (Oracle, SQL Server, DB2, Sybase, Informix, InterBase, SQLBase, MySQL, PostgreSQL and ODBC, SQLite).

ADO Code Examples in Visual C++

ADO Code Examples in Visual C++

ActiveX Data Objects (ADO)

水曜日, 7月 14, 2010

Can you call a C# DLL from a C DLL?

Can you call a C# DLL from a C DLL?


C#

//function i want to call 
public static void GuiDelegate(string message)
{
WriteToWPFGui(message);
}

//notice i need to marshall my string from unmanaged <-> managed, my pinvoke sig
public delegate void CppCallback([MarshalAs(UnmanagedType.LPWStr)] string message);

public static void GuiWriter(CppCallback c)
{
GuiWriter(c);
}

//we need to access C++
[DllImport("C:\\projectName.dll", EntryPoint="CSharp_GuiWriter")] via a dll
public static extern void GuiWriter(CppCallback jarg1);

//CppCallback is defined above
public static CppCallback gui_functor;

delegate void StringDelegate(string message);

//delegate assignment
StringDelegate gui_callback = GuiDelegate;
gui_functor
= new CppCallback(gui_callback);

//this points to pinvoke sig -> pinvoke will step into
projName
.GuiWriter(gui_functor);

C++

typedef void (__stdcall *Callback)(PCWSTR);
static Callback gui;

//Assignment of the delegate to the function pointer
__declspec
(dllexport) void __stdcall CSharp_GuiWriter(void * jarg1)
{
Callback arg1 = (Callback) 0 ;
arg1
= (Callback)jarg1;
gui
= arg1;
}

//invocation
(*gui)(_T("make C# print this text"));


Marshaling between Managed and Unmanaged Code

火曜日, 7月 13, 2010

Restore database from backup without control files

Restore database from backup without control files

  1. sqlplus /nolog
  2. CONNECT / AS SYSDBA
  3. STARTUP NOMOUNT
  4.    CREATE CONTROLFILE DATABASE orcl NORESETLOGS NOARCHIVE
    MAXLOGFILES 32
    LOGFILE GROUP 1 '/oradata1/orcl/redo01.log' SIZE 500M
    GROUP 2 '/oradata1/orcl/redo02.log' SIZE 500M
    DATAFILE
    '/oradata1/orcl/system01.dbf',
    '/oradata1/orcl/undotbs01.dbf'
    CHARACTER SET us7ascii;
  5. ALTER DATABASE MOUNT;
  6. RECOVER DATABASE USING BACKUP CONTROLFILE;
  7. ALTER DATABASE OPEN;

More About:
Oracle 障害回復 制御ファイル バックアップファイルからの回復
Recover database without control files and redo log files

Oracle database Backup and Recovery FAQ

土曜日, 7月 10, 2010

mvn2の設定

環境設定

export M2_HOME=/usr/local/apache-maven
export M2=$M2_HOME/bin
export MAVEN_OPTS="-Xms256m -Xmx512m"

export PATH=$PATH:$JAVA_HOME/bin:$M2

See also CookBook

木曜日, 7月 08, 2010

Change the location Bar in Nautilus to the text mode

Change the location Bar in Nautilus to the text mode

  1. gconftool-2 --type=Boolean --set /apps/nautilus/preferences/always_use_location_entry true
    gconftool-2 --type=Boolean --set /apps/nautilus/preferences/always_use_location_entry false
  2. Ctrl + L

火曜日, 7月 06, 2010

How to create Struts2 project in NetBeans

How to create Struts2 project in NetBeans

“Hello, World” Web Application using Struts 2 in NetBeans IDE 6.1

Developing a Struts 1.x Application with the NetBeans IDE

GlassFish v3 起動手順

GlassFish v3 起動手順

起動:
「C:\glassfishv3\glassfish\bin」フォルダを開いて「startserv.bat」ファイルを実行

停止:
「C:\glassfishv3\glassfish\bin」フォルダを開いて「stopserv.bat」ファイルを実行


管理コンソール:
http://localhost:4848/


Deploy struts 2 to GlassFish
asadmin deploydir --contextroot <URL path> <web application directory that includes WEB-INF>
like ->
asadmin deploydir --contextroot xyz C:\xyz

日曜日, 7月 04, 2010

Rails: MySql lost connection error with Mongrel


以下のようにいずれかを避けることで問題を回避することができるはずである
  1. MySQLのクライアントライブラリを使用したバイナリ版のドライバをインストールする
    sudo gem install mysql
    gem install mysql -- --with-mysql-dir=/usr/local/mysql
  2. Mongrelの使用をやめ、FastCGIなどにする
  3. MySQLのコネクションがタイムアウトしないようcron等で定期的にアクセスする


Rails: MySql lost connection error with Mongrel

Mongrel stops responding a few times per days. Restarting Mongrel helps.
Q: Mongrel stops working if it's left alone for a long time.

If you find that Mongrel stops working after a long idle time and you're using MySQL then you're hitting a bug in the MySQL driver that doesn't properly timeout connections. What happens is the MySQL server side of the connection times out and closes, but the MySQL client doesn't detect this and just sits there.

What you have to do is set:

ActiveRecord::Base.verification_timeout = 14400

Or to any value that is lower than the MySQL server's interactive_timeout setting. This will make sure that ActiveRecord checks the connection often enough to reset the connection.
Setting timeout to avoid bug in MySQL driver that causes Mongrel stopping to work after a long idle time

Mongrel stops responding after period of inactivity


木曜日, 7月 01, 2010

eTicket

eTicket is a PHP-based electronic support ticket system, that can receive tickets via email (pop3/pipe) or a web form. It also offers a ticket manager with many features. An ideal helpdesk solution for any website.