// printf 포맷을 이용하는 OutputDebugString 함수
void Trace(LPCTSTR szFormat, ...)
{
    enum { BUFF_SIZE = 2048 };

    TCHAR szTempBuf[BUFF_SIZE] ;
    va_list vlMarker ;

    va_start(vlMarker,szFormat) ;
    _vstprintf(szTempBuf,szFormat,vlMarker) ;
    va_end(vlMarker) ;

    OutputDebugString(szTempBuf) ;
}

'Dev > C++' 카테고리의 다른 글

VC++ 2005 배포  (0) 2007.06.22
Unhandled C++ Exceptions  (0) 2007.06.19
C++0x  (0) 2007.05.16
GRETA  (0) 2007.05.14
A non-type template-parameter  (0) 2007.05.14

'Dev > C++' 카테고리의 다른 글

Unhandled C++ Exceptions  (0) 2007.06.19
OutputDebugString  (0) 2007.05.23
GRETA  (0) 2007.05.14
A non-type template-parameter  (0) 2007.05.14
Member template specialization  (0) 2007.05.14
콘솔에서 Timer 이벤트 처리 방법을 찾다가 발견한 것.
일명 멀티미디어 타이머라 불리는 ..

일반적인 윈도우의 Timer API 보다 정확도가 높고 윈도우 큐를 이용하지 않아 윈도우 없이도 사용 할수 있다는 장점.


About Multimedia Timers

Multimedia Timer Functions

'Dev > Windows' 카테고리의 다른 글

SWC (Services Without Components)  (0) 2007.08.08
RestartService  (0) 2007.07.19
.NET Enterprise Services 성능 ( vs COM+)  (0) 2007.05.14
DLL 파일 찾는 순서  (0) 2007.05.14
DLL export  (0) 2007.05.14

'Dev > Windows' 카테고리의 다른 글

RestartService  (0) 2007.07.19
MultiMedia Timer  (0) 2007.05.14
DLL 파일 찾는 순서  (0) 2007.05.14
DLL export  (0) 2007.05.14
_beginthread, _beginthreadex  (0) 2007.05.14
1. The directory from which the application loaded.

2. The current directory.

3. The system directory. Use the GetSystemDirectory function to get the path of this directory.

4. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.

5. The directories that are listed in the PATH environment variable.

--
LoadLibrary혹은 DLL을 동적링크할때 특정경로에 관계없이 응용프로그램의 디렉토리에서 먼저 DLL을 로드 하려면 ...

응용프로그램이름 뒤에 ".local" 이란 이름을 가진 빈 파일을 생성한다.
예를들어 응용프로그램 이름이 foo.exe 일때 foo.exe.local 이란 빈 파일을 생성하면 사용하는 DLL을 현재 디렉토리에 있는것 먼저 로드 시킨다.

'Dev > Windows' 카테고리의 다른 글

MultiMedia Timer  (0) 2007.05.14
.NET Enterprise Services 성능 ( vs COM+)  (0) 2007.05.14
DLL export  (0) 2007.05.14
_beginthread, _beginthreadex  (0) 2007.05.14
서버 개체 오류 'ASP 0177 : 800401f3'  (1) 2007.03.29

1. 첫번째 방법
__declspec(dllexport) 키워드를 사용한다.
이경우 calling convention이 "__cdecl" 이면 함수이름 그대로 export되지만 calling convention이 윈도우 표준인 "__stdcall" 이면 함수이름규칙이 변한다

[msdn]
__stdcall Name-decoration convention
An underscore (_) is prefixed to the name. The name is followed by the at sign (@) followed by the number of bytes (in decimal) in the argument list. Therefore, the function declared as int func( int a, double b ) is decorated as follows: _func@12



2. 두번째 방법
.def(Module-Definition) 파일을 작성해 export 시킨다.

EXPORTS
   FunctionName

--
DLL에서 Export된 함수확인하기
1. dumpbin /EXPORTS "DLL이름"
2. Depends툴 이용

'Dev > Windows' 카테고리의 다른 글

.NET Enterprise Services 성능 ( vs COM+)  (0) 2007.05.14
DLL 파일 찾는 순서  (0) 2007.05.14
_beginthread, _beginthreadex  (0) 2007.05.14
서버 개체 오류 'ASP 0177 : 800401f3'  (1) 2007.03.29
VB 지원중단..  (0) 2005.03.23

Create a thread.

unsigned long _beginthread( void( __cdecl *start_address )( void * ), unsigned stack_size, void *arglist );

unsigned long _beginthreadex( void *security, unsigned stack_size, unsigned ( __stdcall *start_address )( void * ), void *arglist, unsigned initflag, unsigned *thrdaddr );


C-Run time 라이브러리를 지원하는 Thread 생성함수들이다.

C-Run time 라이브러리를 지원한다는 뜻은 Thread내에서 C-Run time 함수를 사용했을경우 함수의 정확한 호출을 보장한다는 뜻이다.
ex) strtok


* _beginthread, _beginthreadex의 차이점
_beginthreadex의 경우 상태관리나 NT쪽에서의 보안쪽 파라미터가 추가 되어 있다 (_beginthread의 확장)

Thread 함수의 호출 방식이 틀리다.
_beginthread -> __cdecl
_beginthreadex -> __stdcall


* _endthread, _endthreadex의 차이점
_endthread와 _endthreadex 함수는 _beginthread와 _beginthreadex 에 의해 생성된 Thread함수를 명확히 종료할때 사용하고 Thread함수가 return 되면 자동으로 호출된다.

그러나 _endthreadex는 _endthread와 틀리게 Thread Handle을 자동으로 닫아주지 않는다
그래서 명시적으로 CloseHandle API를 이용해서 Handle을 닫아 주어야 한다

::CloseHandle(handle);

--
MSDN

'Dev > Windows' 카테고리의 다른 글

.NET Enterprise Services 성능 ( vs COM+)  (0) 2007.05.14
DLL 파일 찾는 순서  (0) 2007.05.14
DLL export  (0) 2007.05.14
서버 개체 오류 'ASP 0177 : 800401f3'  (1) 2007.03.29
VB 지원중단..  (0) 2005.03.23
MS의 research site에서 다운 받을수 있는 정규식(Regular Expression ) 라이브러리 이다.

C++에서도 펄과 같은 정규식표현식이 필요할때 사용을 하면 된다.
물론 이것 말고 더 boost의 regex++ 라는 유명한 라이브러리도 있지만 regex++보다 가볍고 몇개의 소스로 배포 되어 있어서 사용하기에 더 편한것 같다.
그리고 regex++보다 낳은 성능을 주장(?)하고 있다

그렇지만 현재 적용중인 몇개의 소스는 regex++ 로 되어 있다


The GRETA Regular Expression Template Archive

  • Fast backtracking regular expression engine.
  • Separately compiled patterns.
  • Matches against C-style NULL-terminated strings, C++-sytle std::string's, or iterator ranges.
  • Template on iterator type and syntax module.
  • Supports Unicode.
  • Syntax is encapsulated in easily customized/replaced modules. (Perl and POSIX syntax modules included.)
  • Match balanced, nested tags with a recursive pattern. Great for HTML/XML/SOAP processing.
  • Many times faster than the .NET/ATL7 regex classes.
  • Consistently outperforms than boost regex++ on short strings; performs competitively on long strongs (see this page for a detailed comparison).

  • 'Dev > C++' 카테고리의 다른 글

    OutputDebugString  (0) 2007.05.23
    C++0x  (0) 2007.05.16
    A non-type template-parameter  (0) 2007.05.14
    Member template specialization  (0) 2007.05.14
    A member template cannot be virtual  (0) 2007.05.14
    14.1.4
    A non-type template-parameter shall have one of the following (optionally cv-qualified) types:

    * integral or enumeration type,
    * pointer to object or pointer to function,
    * reference to object or reference to function,
    * pointer to member.

    [Programming Language C++ (ISO)]

    'Dev > C++' 카테고리의 다른 글

    C++0x  (0) 2007.05.16
    GRETA  (0) 2007.05.14
    Member template specialization  (0) 2007.05.14
    A member template cannot be virtual  (0) 2007.05.14
    sgi STL - Why does Bounds Checker™ say that I have memory leaks?  (0) 2007.05.14
    template 키워드의 다른 또 다른 목적..


    14.2.4
    When the name of a member template specialization appears after . or ->
    in a postfix-expression, or after :: in a qualified-id that explic-
    itly depends on a template-argument (_temp.dep_), the member template
    name must be prefixed by the keyword template. Otherwise the name is
    assumed to name a non-template. [Example:


    class X {
    public:
        template<size_t> X* alloc();
        template<size_t> static X* adjust();
    };

    void f(X* p)
    {
        X* p1 = p->alloc<200>();
        // ill-formed: < means less than

        X* p2 = p->template alloc<200>();
        // fine: < starts explicit qualification
        T::adjust<100>();
        // ill-formed: < means less than
        T::template adjust<100>();
        // fine: < starts explicit qualification
    }


    --end example]


    [Programming Language C++ (ISO)]

    'Dev > C++' 카테고리의 다른 글

    GRETA  (0) 2007.05.14
    A non-type template-parameter  (0) 2007.05.14
    A member template cannot be virtual  (0) 2007.05.14
    sgi STL - Why does Bounds Checker™ say that I have memory leaks?  (0) 2007.05.14
    MinGW - Why is my C++ binary so large?  (0) 2007.05.14
    A member template cannot be virtual. For example:

    class Shape {
      //...
      template virtual bool intersect(const T&) const = 0; // error: virtual template
    };

    This must be illegal. If it were allowed, the traditional virtual function table technique for implementing virtual function could not be used. The linker would have to add a new entry to the virtual table for class Shape each time someone called intersect() with a new argument type.

    - The C++ Programming Language 3rd Edition (Stroustrap)

    Why does Bounds Checker™ say that I have memory leaks?

    This is not an STL bug. It is an artifact of certain kinds of leak detectors.

    In the default STL allocator, memory allocated for blocks of small objects is not returned to malloc. It can only be reused by subsequent allocate requests of (approximately) the same size. Thus programs that use the default may appear to leak memory when monitored by certain kinds of simple leak detectors. This is intentional. Such "leaks" do not accumulate over time. Such "leaks" are not reported by garbage-collector-like leak detectors.

    The primary design criterion for the default STL allocator was to make it no slower than the HP STL per-class allocators, but potentially thread-safe, and significantly less prone to fragmentation. Like the HP allocators, it does not maintain the necessary data structures to free entire chunks of small objects when none of the contained small objects are in use. This is an intentional choice of execution time over space use. It may not be appropriate for all programs. On many systems malloc_alloc may be more space efficient, and can be used when that is crucial.

    The HP allocator design returned entire memory pools when the entire allocator was no longer needed. To allow this, it maintains a count of containers using a particular allocator. With the SGI design, this would only happen when the last container disappears, which is typically just before program exit. In most environments, this would be highly counterproductive; free would typically have to touch many long unreferenced pages just before the operating system reclaims them anyway. It would often introduce a significant delay on program exit, and would possibly page out large portions of other applications. There is nothing to be gained by this action, since the OS reclaims memory on program exit anyway, and it should do so without touching that memory.

    In general, we recommend that leak detection tests be run with malloc_alloc. This yields more precise results with GC-based detectors (e.g. Pure Atria's PurifyTM), and it provides useful results even with detectors that simply count allocations and deallocations.

    + Recent posts