Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]qtcreator under Wine ( MinGw compilant ) windows.h program

[SOLVED]qtcreator under Wine ( MinGw compilant ) windows.h program

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    heatblazer
    wrote on last edited by
    #1

    Hello. I am trying again to compile a windows exe under wine+qtcreator. I am wondering why this code does not compile and reports an error.
    @
    #ifdef _WIN32
    #include "Service.h"
    #include <stdio.h>
    SERVICE_STATUS ServiceStatus;
    SERVICE_STATUS_HANDLE hStatus;
    int InitService() {
    int result = WriteToLog("Monitoring started.");
    return result;
    }

    int WriteToLog(char str) {
    FILE
    fp;
    fp = fopen(LOG_FILE, "a+");
    if ( ! fp) return -1;
    fprintf(fp, "%s\n", str);
    fclose(fp);
    return 0;
    }

    int ServiceMain(int argc, char argv[]) {
    int error = InitService();
    if ( error ) {
    ServiceStatus.dwCurrentState = SERVICE_STOPPED;
    ServiceStatus.dwWin32ExitCode = -1;
    SetServiceStatus(hStatus, &ServiceStatus);
    return 1;
    }
    ServiceStatus.dwCurrentState = SERVICE_RUNNING;
    SetServiceStatus(hStatus, &ServiceStatus);
    return 0;
    }
    int mainO(int argc, char
    * argv) {
    SERVICE_TABLE_ENTRY ServiceTable[2];
    ServiceTable[0].lpServiceName = "MemoryStatus" ;
    ServiceTable[0].lpServiceProc = (LP_SERVICE_MAIN_FUNCTION) ServiceMain ;
    printf("%d is status \n", StartServiceCtrlDispatcher(ServiceTable));
    }
    @
    qtcreator reports errors in mainO ServiceTable[0].lpServiceName and lpServiceProc. The errors are as follows:
    @
    cannot convert 'const char[13]' to LPWSTR {aka wchar_t*} in assignment
    LP_SERVICE_MAIN_FUNCTION was not declared in this scope
    @
    Should I include something in pro file?

    1 Reply Last reply
    0
    • hskoglundH Offline
      hskoglundH Offline
      hskoglund
      wrote on last edited by
      #2

      Hi, try change lines 35 and 36 to:
      @
      ServiceTable[0].lpServiceName = L"MemoryStatus" ;
      ServiceTable[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION) ServiceMain ;
      @

      1 Reply Last reply
      0
      • H Offline
        H Offline
        heatblazer
        wrote on last edited by
        #3

        OK, I was able to just cast to wchar_t* the string. Ive added to pro file windows.h which for god sake, I ve found in Qt Dir :) This is nice feat. But I still got that weird err:
        @
        ServiceTable[0].lpServiceProc = (LP_SERVICE_MAIN_FUNCTION) ServiceMain ;
        @
        @
        Z:\home\ilian\QT5\SampleGame\Service.cpp:38: error: 'LP_SERVICE_MAIN_FUNCTION' was not declared in this scope
        ServiceTable[0].lpServiceProc = (LP_SERVICE_MAIN_FUNCTION) ServiceMain ;
        ^
        Z:\home\ilian\QT5\SampleGame\Service.cpp:38: error: expected ';' before 'ServiceMain'
        ServiceTable[0].lpServiceProc = (LP_SERVICE_MAIN_FUNCTION) ServiceMain ;
        ^
        @

        1 Reply Last reply
        0
        • H Offline
          H Offline
          heatblazer
          wrote on last edited by
          #4

          Thank you very much! I`ve figured it by casting the string to wchar_t* but never got the idea it was LPSERVICE not LP_SERVICE... damn windows.
          [quote author="hskoglund" date="1410538438"]Hi, try change lines 35 and 36 to:
          @
          ServiceTable[0].lpServiceName = L"MemoryStatus" ;
          ServiceTable[0].lpServiceProc = (LPSERVICE_MAIN_FUNCTION) ServiceMain ;
          @[/quote]

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved