Şimdi Ara

DERLEYİCİ HATASI

Daha Fazla
Bu Konudaki Kullanıcılar: Daha Az
2 Misafir - 2 Masaüstü
5 sn
5
Cevap
0
Favori
472
Tıklama
Daha Fazla
İstatistik
  • Konu İstatistikleri Yükleniyor
Öne Çıkar
0 oy
Sayfa: 1
Giriş
Mesaj
  • aşağıda verdiğim kodu derlediğimde resimdeki hatayı veriyor.Kullandığım derleyici visual studio 13.Problemi nasıl çözebilirim acaba?
     DERLEYİCİ HATASI


    kaynak kod ise burada :
     
    /*++

    Copyright (c) Tahribat 2001-2012. All rights reserved.

    Module Name:

    main.c

    Abstract:

    Right Ctrl tusuna basilinca secilen metini google translate ile cevirir,
    cevrilmis metini mesaj kutusu ile gosterir.

    --*/

    #define _WIN32_WINNT 0x501
    #define _CRT_SECURE_NO_WARNINGS

    #define HOSTNAME "www.google.com"

    #include <Windows.h>
    #include <stdio.h>
    #include <time.h>
    #include <resource.h>

    HHOOK hHook;
    HANDLE hMutex;
    HWND hwnd, hNextWnd;
    HINSTANCE ghInstance;
    time_t tMsg;
    int Lock, ExitLock;
    char buffer[256] = { 0 };

    //
    // Bu request degisebilir simdilik bu sekilde calisiyor %s yerine metin gelecek
    //
    char request[4096] =
    "GET /?langpair=en|tr&text=%s HTTP/1.0\r\n"
    "Host: translate.google.com\r\n"
    "User-Agent: App/1.7\r\n\r\n";

    void ShowMessage(HWND hwndOwner, WCHAR *msg, WCHAR* capt)
    {
    MSGBOXPARAMSW msgParam;
    memset(&msgParam, 0, sizeof(msgParam));

    msgParam.cbSize = sizeof(msgParam);
    msgParam.hwndOwner = hwndOwner;
    msgParam.hInstance = ghInstance;
    msgParam.lpszText = msg;
    msgParam.lpszCaption = capt;
    msgParam.dwStyle = MB_OK | MB_USERICON;
    msgParam.lpszIcon = MAKEINTRESOURCEW(IDI_ICON1);
    msgParam.dwLanguageId = LANG_TURKISH;

    //
    // Google translate iconu ile mesaji gostermek icin MessageBoxun gelismisi
    //
    MessageBoxIndirectW(&msgParam);
    }

    SOCKET GetConnectedSocket(const char* hostname, short port)
    {
    SOCKET client = 0;
    struct hostent *host = NULL;
    struct sockaddr_in info = { 0 };

    //
    // Translate.google.com u coz ve baglan, bu fonksiyon bazen cok uzun
    // sure donmuyor internet baglantisi sikintili ise
    //
    if (!(host = gethostbyname(hostname)))
    {
    return INVALID_SOCKET;
    }

    info.sin_family = AF_INET;
    info.sin_port = htons((short)port);
    info.sin_addr = *((struct in_addr *)host->h_addr);

    if (INVALID_SOCKET == (client = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)))
    {
    return INVALID_SOCKET;
    }

    if (connect(client, (struct sockaddr *)&info, sizeof(struct sockaddr)))
    {
    closesocket(client);
    return INVALID_SOCKET;
    }
    return client;
    }

    void SendCtrlC(void)
    {
    GUITHREADINFO tInfo;

    memset(&tInfo, 0, sizeof(tInfo));
    tInfo.cbSize = sizeof(tInfo);

    GetGUIThreadInfo(0, &tInfo);

    //
    // Aslinda burda Ctrl yollamiyoruz sadece C yolluyoruz, cunku zaten
    // Ctrl ye basilmis :) birakma kodundan once bu mesaji yolluyoruz boylece
    // Ctrl+C ye basilmis, secili metin kopyalanmis oluyor
    //
    PostMessage(tInfo.hwndFocus, WM_KEYDOWN, 'C', 0);
    PostMessage(tInfo.hwndFocus, WM_KEYUP, 'C', 0);
    }

    DWORD WINAPI TranslateThread(
    LPVOID lpParameter
    )
    {
    int i, j, len = 0;
    char *str, *ptr;
    char buf[32 * 1024] = { 0 };
    char shadow[1024] = { 0 };
    WCHAR shadowU[1024] = { 0 };
    char trChar[32] = "öÖşŞçÇıİğĞüÜ";
    WCHAR trwChar[32] = L"öÖşŞçÇıİğĞüÜ";
    GUITHREADINFO tInfo;
    SOCKET sock = INVALID_SOCKET;

    memset(&tInfo, 0, sizeof(tInfo));
    tInfo.cbSize = sizeof(tInfo);

    GetGUIThreadInfo(0, &tInfo);

    if (buffer[0] == '\a')
    {
    MessageBoxW(tInfo.hwndFocus,
    L"Seçilen yazi 255 karakterden kısa olmadıdır",
    L"Uyarı",
    48);
    goto Exit;
    }

    //
    // Oncelikle translate.google.com a baglanmis bir soket olustur
    //
    sock = GetConnectedSocket(HOSTNAME, 80);
    if (sock == INVALID_SOCKET) {
    MessageBoxW(tInfo.hwndFocus, L"İnternete Bağlanılamadı", L"Uyarı", 48);
    goto Exit;
    }

    //
    // Translate icin yollayacagimiz metindeki bazı karakterleri space ile
    // degistir, yazilamayanlar yerine de _ koy
    //
    for (i = 0; buffer[i]; i++)
    {
    if (buffer[i] == '\r' || buffer[i] == '\n' ||
    buffer[i] == '\\' || buffer[i] == '%')
    {
    buffer[i] = ' ';
    }
    else if (!isprint(buffer[i]))
    {
    buffer[i] = '_';
    }

    len += sprintf(shadow + len, "%%%X", (unsigned char)buffer[i]);
    }

    //
    // Cevrilecek datayi yolla bakalim
    //
    len = sprintf(buf, request, shadow);
    send(sock, buf, len, 0);

    memset(buf, 0, sizeof(buf));
    memset(shadow, 0, sizeof(shadow));

    len = 0;

    //
    // </html> i gorene kadar sayfayi yuklemeye devam et
    //
    while (TRUE)
    {
    int ret = 0;
    ret = recv(sock, buf + len, sizeof(buf) - len, 0);
    if (ret <= 0) {
    break;
    }
    if (strstr(buf, "</Html>") || strstr(buf, "</html>")) {
    break;
    }
    len += ret;
    }

    closesocket(sock);
    str = buf;

    //
    // Burasi kodun en guvenilmez yeri, gelen sayfada cevrilmis metin #fff'">
    // karakterlerinden sonra geliyor, ama yarin degisebilir bu :)
    //
    while (TRUE)
    {
    str = strstr(str, "#fff'\">");
    if (str == NULL) {
    break;
    }

    ptr = strchr(str, '<');
    if (ptr == NULL) {
    break;
    }
    *ptr = 0;

    sprintf(shadow + strlen(shadow), "%s ", str + strlen("#fff'\">"));
    str = ptr + 1;
    }

    //
    // Gelen stringi yani cevrilmis metni unicode a cevir ve ekrana bas
    //
    if (*shadow) {
    int length = strlen(trChar);

    for (i = 0; shadow[i]; i++)
    {
    for (j = 0; j<length; j++)
    {
    if (shadow[i] == trChar[j]) {
    shadowU[i] = trwChar[j];
    }
    }

    if (shadowU[i] == 0) {
    shadowU[i] = shadow[i];
    }
    }
    ShowMessage(tInfo.hwndFocus, shadowU, L"Google Translate");
    }

    Exit:
    Lock = 0;
    memset(buffer, 0, sizeof(buffer));
    return 0;
    }

    DWORD WINAPI ThreadExit(
    LPVOID lpParameter
    )
    {
    GUITHREADINFO tInfo;

    if (ExitLock) {
    return 0;
    }
    ExitLock = 1;

    memset(&tInfo, 0, sizeof(tInfo));
    tInfo.cbSize = sizeof(tInfo);

    GetGUIThreadInfo(0, &tInfo);

    if (MessageBoxW(tInfo.hwndFocus,
    L"Programdan çıkmak İstiyor musun?",
    L"Google Translate",
    MB_YESNOCANCEL | MB_ICONQUESTION
    ) == IDYES) {
    SendMessage(hwnd, WM_CLOSE, 0, 0);
    }

    ExitLock = 0;
    return 0;
    }

    LRESULT CALLBACK LowLevelKeyboardProc(
    int nCode,
    WPARAM wParam,
    LPARAM lParam
    )
    {
    //
    // Burasi hook proseduru, her tusa basildiginda bir kere calisir
    //
    KBDLLHOOKSTRUCT *kbhook = (KBDLLHOOKSTRUCT*)lParam;

    //
    // Right Ctrl tusu birakildiginda bu kod calisir, tus basilma zamanini
    // kaydeder ve focus olan pencerenin mesaj kuyruguna Ctrl+C yollar
    //
    if (kbhook->vkCode == VK_RCONTROL)
    {
    if (wParam == WM_KEYUP) {
    tMsg = time(NULL);
    SendCtrlC();
    }
    }

    //
    // Basilmis tus F10 ise, cikis dialogunu soran threadi baslat
    //
    if (wParam == WM_KEYUP && kbhook->vkCode == VK_F10)
    {
    HANDLE hThread = CreateThread(NULL, 0, ThreadExit, NULL, 0, NULL);
    CloseHandle(hThread);
    }

    return CallNextHookEx(NULL, nCode, wParam, lParam);
    }

    LRESULT CALLBACK WindowProcedure(
    HWND hwnd,
    UINT message,
    WPARAM wParam,
    LPARAM lParam
    )
    {
    HGLOBAL hglb;
    LPTSTR lptstr;
    DWORD cbLen = 0;

    //
    // Clipboard degismis mesaji
    //
    if (message == WM_DRAWCLIPBOARD)
    {
    //
    // Degisiklik bizden mi kaynaklaniyor, aksi halde return
    //
    if ((time(NULL) - tMsg) > 1)
    {
    return 0;
    }

    if (!OpenClipboard(NULL)) {
    return 0;
    }

    //
    // Clipboard daki data text mi, oyleyse oku, degilse return
    //
    if (!IsClipboardFormatAvailable(CF_TEXT)) {
    EmptyClipboard();
    CloseClipboard();
    return 0;
    }

    hglb = GetClipboardData(CF_TEXT);
    if (hglb == NULL)
    {
    CloseClipboard();
    return 0;
    }

    lptstr = (LPTSTR)GlobalLock(hglb);
    if (lptstr == NULL) {
    CloseClipboard();
    return 0;
    }

    cbLen = strlen((char*)lptstr);
    if (cbLen < sizeof(buffer)) {
    memcpy(buffer, lptstr, cbLen);
    }
    else {
    buffer[0] = '\a';
    }

    GlobalUnlock(hglb);
    CloseClipboard();

    if (hNextWnd != NULL) {
    SendMessage(hNextWnd, message, wParam, lParam);
    }

    //
    // Data okundu, aktif bir ceviri islemi yoksa, ceviri threadini baslat
    //
    if (Lock == 0)
    {
    HANDLE hThread = CreateThread(NULL, 0, TranslateThread, NULL, 0, NULL);
    CloseHandle(hThread);
    Lock = 1;
    }

    return 0;
    }
    else if (message == WM_CHANGECBCHAIN)
    {
    //
    // Bir baska viewer listeden cikti, artik clipboard degisiklikleri
    // ona gitmeyecek, bizde onu aradan cikarip listeyi duzenliyoruz
    //
    if ((HWND)wParam == hNextWnd) {
    hNextWnd = (HWND)lParam;
    }
    else if (hNextWnd != NULL) {
    SendMessage(hNextWnd, message, wParam, lParam);
    }
    return 0;
    }
    else if (message == WM_CLOSE)
    {
    //
    // Temizlik islemlerini yap programi kapat
    //
    ChangeClipboardChain(hwnd, hNextWnd);
    WSACleanup();
    UnhookWindowsHookEx(hHook);
    CloseHandle(hMutex);
    ExitProcess(0);
    }
    else {
    return DefWindowProc(hwnd, message, wParam, lParam);
    }
    }

    int WINAPI WinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow
    )
    {
    MSG messages;
    WNDCLASSEX wincl;
    CHAR szClassName[] = "WindowsApp";
    WSADATA wsaData;

    ghInstance = hInstance;

    //
    // Programin ayni anda sadece 1 orneginin calismasi icin
    //
    if ((hMutex = CreateMutex(NULL, FALSE, "Translate")) &&
    GetLastError() == ERROR_ALREADY_EXISTS)
    {
    MessageBoxW(0,
    L"Bu programdan sadece bir örnek çalıştırılabilir",
    L"Uyarı",
    48);
    return 0;
    }

    ShowMessage(0,
    L"Google Instant Translate by D.K.\nÇıkmak için F10'a basın.",
    L"Google Translate");

    WSAStartup(MAKEWORD(2, 2), &wsaData);

    //
    // LowLevel keyboard hook atiliyor, F10 ve Ctrl i yakalamak icin
    //
    hHook = SetWindowsHookEx(WH_KEYBOARD_LL,
    LowLevelKeyboardProc,
    hInstance,
    0);
    if (hHook == NULL) {
    goto ErrorExit;
    }

    //
    // Gorunmeyen pencereyi yarat, window mesajlarını alabilmemiz icin
    //
    wincl.hInstance = hInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;
    wincl.style = CS_DBLCLKS;
    wincl.cbSize = sizeof(WNDCLASSEX);

    wincl.hIcon = LoadIcon(NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;
    wincl.cbClsExtra = 0;
    wincl.cbWndExtra = 0;
    wincl.hbrBackground = (HBRUSH)COLOR_BACKGROUND;

    if (!RegisterClassEx(&wincl)) {
    goto ErrorExit;
    }

    hwnd = CreateWindowEx(0,
    szClassName,
    "Windows App",
    WS_OVERLAPPEDWINDOW,
    CW_USEDEFAULT,
    CW_USEDEFAULT,
    0,
    0,
    HWND_DESKTOP,
    NULL,
    hInstance,
    NULL
    );
    if (hwnd == NULL) {
    goto ErrorExit;
    }

    //
    // Clipboard viewer ekle boylece clipboard degistiginde bize mesaj gelecek
    //
    hNextWnd = SetClipboardViewer(hwnd);
    if (hNextWnd == NULL)
    {
    if (GetLastError() != ERROR_SUCCESS) {
    goto ErrorExit;
    }
    }

    //
    // Mesaj dongusune gir, bu donguden program sonlanana kadar cikilmayacak
    // WM_CLOSE mesajinin handle edildigi yerde program sonlandiriliyor
    //
    while (GetMessage(&messages, NULL, 0, 0))
    {
    TranslateMessage(&messages);
    DispatchMessage(&messages);
    }

    //
    // Hata durumunda ortaligi temizle tozol
    //
    ErrorExit:
    WSACleanup();
    CloseHandle(hMutex);
    UnhookWindowsHookEx(hHook);
    return 1;
    }



    < Bu mesaj bu kişi tarafından değiştirildi sparcoysn -- 23 Ağustos 2014; 23:26:18 >



    _____________________________




  • Bu şekilde dener misin ?

    msgParam.lpszIcon = MAKEINTRESOURCEW(NULL, IDI_ICON1);
    _____________________________
  • 11 tane hata oluştu ve MAKEINTRESOURCEW(NULL, IDI_ICON1) parametre sayısı çok fazla diyor.
    _____________________________
  • hatayı el ile yazabilrmisiniz telefondan resimde okunmuyor:

    MAKEINTRESOURCE(IDI_ICON1);

    < Bu ileti mini sürüm kullanılarak atıldı >
    _____________________________
  • http://en.wikibooks.org/wiki/Windows_Programming/Resource_Script_Reference

    ICON bölümünü bir incele.



    < Bu mesaj bu kişi tarafından değiştirildi kneestronk -- 25 Ağustos 2014; 15:00:40 >
    _____________________________
  • Yapay Zeka’dan İlgili Konular
    Xampp Hatası Yardım :(
    12 yıl önce açıldı
    Daha Fazla Göster
    
Sayfa: 1
- x
Bildirim
mesajınız kopyalandı (ctrl+v) yapıştırmak istediğiniz yere yapıştırabilirsiniz.