troubleshooting Question

return a value

Avatar of zeurx
zeurxFlag for United States of America asked on
C++System Programming
6 Comments2 Solutions420 ViewsLast Modified:
OK guys, get this and get all my points i currently have...

A program runs fine in an IDE under debug, but when you execute it from exporer the just in time debugger kicks in but does not break in ASM.  Also it only has a problem when loading a dll.

[Edit Code Snips following]
I have found that when i return an LPCTSTR is when it crashes, still do not understand why it will work when ran from the IDE

LPCTSTR *Initialize()
      // Initialize plugin
      args = new LPCTSTR;
      args[BCONNECT] = "Connect"; //Connect button text
      args[BDISCONNECT] = "Disconnect"; //Disconnect button text
      args[MAP] = "MapDrive";
      args[UNMAP] = "UnMapDrive";
      args[DOMAIN] = "DOMAIN";
      // Drive letter and server, 2 slots per network drive
      int NumOfDrives = 1; //The number of network drives
      Drives = new LPCTSTR;
      Drives[0] = "Z:"; //Drive letter to use
      Drives[1] = "localhost"; //Server to use
      Drives[2] = ""; //Fallback IP
      // Add drives and servers to main array
      for(int i = 0; i <= NumOfDrives*3-1; i++)
            args[DRIVES+i] = Drives[i];
            args[DRIVES+i+1] = NULL;
      return args;

typedef LPCTSTR *(*Initialize)(void);
Initialize Init = (Initialize)::GetProcAddress(PlugDll,"Initialize");
      MessageBox("Failed to initialize",0, MB_ICONERROR);
// Setup local vars
DriveArgs = NULL;
DriveArgs = new LPCTSTR;
// Call initialize function
DriveArgs = Init();

Now if i break before i call the dll function my program wont crash so i know it is that function on the dll. could it be the returning of the LPCTSTR *args?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros