[Tutorial with Source] GetPidsByProcessName menu

User Tag List

Page 2 of 2 FirstFirst 12
Results 16 to 18 of 18
  1. #16
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In regards to references vs pointers:
    There are times when pointers are appropriate (for example when 'null' is an appropriate value and not an error). There is no such thing as a null-reference so use of a pointer in the case where the parameter is optional is quite acceptable.

    In regards to RAII:
    shared_ptr is designed for pointers. Handles and other OS resources are not pointers.

    In regards to TCHAR:
    TCHAR resolves to wchar_t when compiling for Unicode, and char when compiling for MBCS. Honestly though, I see no reason to use anything other than Unicode when you're doing development of Windows libraries. Windows uses Unicode internally, so by using narrow strings in your application you're slowing it down because for each API call that works with strings it needs to convert the narrow strings to wide strings, call the wide API call, then convert any wide strings back to narrow (if appliciable). If you just use wide strings to begin with you avoid a lot of overhead.

    In answer to your actual concern though, you want to use basic_string<TCHAR> so you get a wstring under Unicode and a string under MBCS.

    Again though, I don't even bother with that, I just use wide strings everywhere because it's pointless to use narrow ones.

    [Tutorial with Source] GetPidsByProcessName
  2. #17
    Ellesar1's Avatar Member
    Reputation
    20
    Join Date
    Feb 2009
    Posts
    78
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for your clarification about the "call by pointer" use.

    as a reason to use a std::basic_string<TCHAR> I see that PROCESSENTRY32.szExeFile has type TCHAR* and therefore is not forced to be unicode


    to RAII: I've implemented it with a shared_ptr now which works well and without additional dependencies.
    will keep your posted "EnsureCleanup" in mind to use when the project makes more use of these HANDLE's etc.
    Last edited by Ellesar1; 10-13-2009 at 03:25 PM.

  3. #18
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1358
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/6
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Ellesar1 View Post
    thanks for your clarification about the "call by pointer" use.

    as a reason to use a std::basic_string<TCHAR> I see that PROCESSENTRY32.szExeFile has type TCHAR* and therefore is not forced to be unicode


    to RAII: I've implemented it with a shared_ptr now which works well and without additional dependencies.
    will keep your posted "EnsureCleanup" in mind to use when the project makes more use of these HANDLE's etc.
    Yes, but as I said, I always compile with Unicode, so the fact that it's a TCHAR is irrelevant because it will always end up resolving to a wchar_t. If you wish to support multiple character sets that's fine, but I honestly wouldn't bother. I use all the wide APIs and structures explicitly so I don't get the TCHAR version but instead get the WCHAR version.

    I know a shared_ptr will work fine in this specific instance, however the point I was trying to make was that although it will work fine it is still not the 'correct' thing to do as it implies that the resource is a pointer of some sort.

    Anyway, doesn't really matter I guess, just being pedantic.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Coloa Fishbot - Simple fishbot with source
    By grosfilsdepute in forum World of Warcraft Bots and Programs
    Replies: 5
    Last Post: 10-20-2009, 08:48 AM
  2. Replies: 6
    Last Post: 02-09-2009, 02:44 AM
  3. AC Web Ultimate Repack for 2.3.0 Tutorial! With Pictures For Newbies
    By Skozzan in forum WoW EMU Guides & Tutorials
    Replies: 140
    Last Post: 02-04-2008, 11:48 AM
  4. Auto-Queue/Anti-AFK HonorBot With Source Code (c++)
    By Flying Piggy in forum World of Warcraft Bots and Programs
    Replies: 12
    Last Post: 09-12-2007, 11:13 AM
  5. All-Jumps {(Jumping Script)} With Source!
    By iHack in forum World of Warcraft Bots and Programs
    Replies: 55
    Last Post: 08-01-2007, 03:27 AM
All times are GMT -5. The time now is 10:10 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search