dnsapi.dll

This is a discussion on dnsapi.dll within the Windows Programming forums, part of the Platform Specific Boards category; Hello.. I want to call dnsapi.dll and get DnsQuery_A for a specific domain.. DNS_RECORD *pQueryRec; is where the results are ...

  1. #1
    l2u
    l2u is offline
    Registered User
    Join Date
    May 2006
    Posts
    630

    dnsapi.dll

    Hello..

    I want to call dnsapi.dll and get DnsQuery_A for a specific domain..
    DNS_RECORD *pQueryRec; is where the results are stored.

    Now I want to copy pNameExchange to server:
    Code:
    char *server;
    server = new char[strlen(pQueryRec->Data.MX.pNameExchange) + 1];
    strcpy(server, pQueryRec->Data.MX.pNameExchange);
    And I get:
    cannot convert parameter 1 from 'PWSTR' to 'const char *'
    for strlen and strcpy.

    I've looked what PWSTR is and couldnt find any good answers. Not sure if I should go with casting, or what else should I do?

  2. #2
    I am me, who else?
    Join Date
    Oct 2002
    Posts
    250
    You cannot use it like that. PWSTR is in windows at least a type def for a null terminated 16-bit unicode string. Meaning simple char* types of strings will not work. WCHAR is a multi-byte CHAR (depending on platforms and whatnot, this may vary, but on Win xp I am pretty sure it is). You need to use a WCHAR for this to work properly. Simply replace all references to char with WCHAR and you should be set. If this is on windows you will be fine, otherwise it could be more problematic.

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    It looks like you have UNICODE defined. You can either turn this off in the compiler settings, or explicitly use the DNS_RECORDA structure (probably a good idea as you are using the DnsQuery_A function).

    There is an example of using the DNS API here and another one here.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21