Search

'path'에 해당되는 글 2건

  1. 2016.09.28 hiredis MFC import Visual Studio 2013
  2. 2016.08.30 MFC Drag And Drop FileName 만 추출

hiredis MFC import Visual Studio 2013

Programming/Redis 2016. 9. 28. 11:49 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

hiredis MFC import




Hiredis is a minimalistic C client library for the Redis database.

It is minimalistic because it just adds minimal support for the protocol, but at the same time it uses a high level printf-alike API in order to make it much higher level than otherwise suggested by its minimal code base and the lack of explicit bindings for every Redis command.


1. Download Hiredis

Project Site : https://github.com/redis/hiredis


[Clone or download] [Download ZIP]




2. Include Hiredis Header Files



3. Config Hiredis Header Files Path







4. Build Hiredis Library File


Open Hiredis Project





Build Hiredis Project





5. Config Hiredis Library File Path





6. Sample Code




#include 
#include 
#include 

#include "hiredis.h"

#ifdef HIREDIS_WIN
#define snprintf sprintf_s
#endif

int main(void) {
    unsigned int j;
    redisContext *c;
    redisReply *reply;

    struct timeval timeout = { 1, 500000 }; // 1.5 seconds
    c = redisConnectWithTimeout((char*)"127.0.0.1", 6379, timeout);
    if (c->err) {
        printf("Connection error: %s\n", c->errstr);
        exit(1);
    }

    /* PING server */
    reply = redisCommand(c,"PING");
    printf("PING: %s\n", reply->str);
    freeReplyObject(reply);

    /* Set a key */
    reply = redisCommand(c,"SET %s %s", "foo", "hello world");
    printf("SET: %s\n", reply->str);
    freeReplyObject(reply);

    /* Set a key using binary safe API */
    reply = redisCommand(c,"SET %b %b", "bar", 3, "hello", 5);
    printf("SET (binary API): %s\n", reply->str);
    freeReplyObject(reply);

    /* Try a GET and two INCR */
    reply = redisCommand(c,"GET foo");
    printf("GET foo: %s\n", reply->str);
    freeReplyObject(reply);

    reply = redisCommand(c,"INCR counter");
    printf("INCR counter: %lld\n", reply->integer);
    freeReplyObject(reply);
    /* again ... */
    reply = redisCommand(c,"INCR counter");
    printf("INCR counter: %lld\n", reply->integer);
    freeReplyObject(reply);

    /* Create a list of numbers, from 0 to 9 */
    reply = redisCommand(c,"DEL mylist");
    freeReplyObject(reply);
    for (j = 0; j < 10; j++) {
        char buf[64];

        snprintf(buf,64,"%d",j);
        reply = redisCommand(c,"LPUSH mylist element-%s", buf);
        freeReplyObject(reply);
    }

    /* Let's check what we have inside the list */
    reply = redisCommand(c,"LRANGE mylist 0 -1");
    if (reply->type == REDIS_REPLY_ARRAY) {
        for (j = 0; j < reply->elements; j++) {
            printf("%u) %s\n", j, reply->element[j]->str);
        }
    }
    freeReplyObject(reply);

    return 0;
}


7. Sample Monitor






'Programming > Redis' 카테고리의 다른 글

Redis Client Connect Test  (0) 2016.10.26
Hiredis Subscribe/Publish with CWinThread  (0) 2016.10.05
How to use Pub/sub with hiredis in C++?  (0) 2016.09.29
hiredis fatal error C1853:  (0) 2016.09.29
Windows7 Redis 설치 및 실행  (0) 2016.09.27

MFC Drag And Drop FileName 만 추출

Programming/MFC 2016. 8. 30. 11:38 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.


MFC Drag And Drop FileName 만 추출


	// TODO: 여기에 메시지 처리기 코드를 추가 및/또는 기본값을 호출합니다.
	int nFiles;


	char szPathName[MAX_PATH];  // 파일 경로명이 들어간다.
	
	// 드래그앤드롭된 파일의 갯수
	nFiles = ::DragQueryFile(hDropInfo, 0xFFFFFFFF, szPathName, MAX_PATH);







	for (int i = 0; i < nFiles; i++)
	{
		// 파일의 경로 얻어옴
		::DragQueryFile(hDropInfo, i, szPathName, MAX_PATH);
		MessageBox(szPathName, "DropAndDropFile");
		char* szFileName = szPathName;
		// FileName 만을 찾기위한 반복문
		for (int j = 0; j < strlen(szPathName); j++)
		{
			if (szPathName[j] == '\\')
			{
				szFileName = szPathName + j + 1;
			}
		}
		m_ListCtrl.AddString(szFileName);
		m_ListCtrl.SetHorizontalExtent(2600);
	}

'Programming > MFC' 카테고리의 다른 글

MFC Alert MessageBox2  (0) 2016.09.06
MFC Alert MessageBox  (0) 2016.09.06
MFC File Icon Drag and Drop  (0) 2016.08.30
MFC Dialog 가 이상한 위치에 배치, (0,0)에 배치  (0) 2016.08.24
MFC CTextProgressCtrl  (0) 2016.08.17