need help with building DLL

This is a discussion on need help with building DLL within the C++ Programming forums, part of the General Programming Boards category; This is just one of the functions im making for a 3rd party DLL for a different language. Code: #ifndef ...

  1. #1
    Programmer Frantic-'s Avatar
    Join Date
    Dec 2004
    Posts
    114

    need help with building DLL

    This is just one of the functions im making for a 3rd party DLL for a different language.

    Code:
    #ifndef EXPORT
    #define EXPORT __declspec (dllexport)
    #endif
    
    // MESSAGE BOX OK ////////////////////////////////////////////
    EXPORT void XSDKMESSAGEBOX_OK(LPSTR smessage, LPSTR stitle)
    {
    
    	if(smessage != "")
    	{
    		MessageBox(NULL,smessage,stitle,MB_OK);
    	}
    	else if(smessage == "")
    	{
    	MessageBox(NULL, "Error Code MBO162: \"LPSTR smessage\" is invalid.", 
     "XSDK Error", MB_OK | MB_ICONSTOP);
    	}
    
    }
    Now everything compiles just fine, but when I go to use it, and i enter "" for the message, it is still displaying the normal box and now the error box. Is something wrong with my logic, or something else.

  2. #2
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    You can't do comparisons like that with char arrays. You can with the STL string class, but that's a different ball game. Try using
    Code:
    smessage[0]!='\0'
    instead of your first comparison, and then just an else instead of an else if.
    Away.

  3. #3
    Programmer Frantic-'s Avatar
    Join Date
    Dec 2004
    Posts
    114
    ok now how about this one. When the users enters the correct word, it goes to the error screen. If i entered "OK" where smessage goes, it would give me an error.

    Code:
    // MESSAGE BOX //////////////////////////////////////
    EXPORT void XSDKMESSAGEBOX(LPSTR smessage, LPSTR stitle, LPSTR sicon, LPSTR stype)
    {
    
    	if(smessage != "")
    	{
    		if (stype == "OK")
    		{
    			if(sicon == "EXCLAMATION")
    			{
    				MessageBox(NULL,smessage,stitle, MB_OK | MB_ICONEXCLAMATION);
    			}
    			else if (sicon == "INFORMATION")
    			{
    				MessageBox(NULL,smessage, stitle, MB_OK | MB_ICONINFORMATION);
    			}
    			else if (sicon == "QUESTION")
    			{
    				MessageBox(NULL,smessage, stitle, MB_OK | MB_ICONQUESTION);
    			}
    			else if (sicon == "STOP")
    			{
    				MessageBox(NULL,smessage,stitle, MB_OK | MB_ICONSTOP);
    			}
    			else
    			{
    				MessageBox(NULL,"Error Code MBME160: \"LPSTR sicon\" is invalid.", "XSDK Error", MB_OK | MB_ICONSTOP);
    			}
    		}
    		else if (stype == "OKCANCEL") 
    //..... and so on

  4. #4
    Programmer Frantic-'s Avatar
    Join Date
    Dec 2004
    Posts
    114
    never mind i got it :P

  5. #5
    Registered User
    Join Date
    Jun 2005
    Posts
    6,434
    Quote Originally Posted by Frantic-
    never mind i got it :P
    Well done. Presumably, when you "got it" you realised that you either need to use std::string or compare strings using strcmp().

    What you described is a pretty common problem encountered by many beginners. Even though this sort of thing is covered pretty early on in most introductory texts, few beginners seem to read that far before they try cutting code.

  6. #6
    Programmer Frantic-'s Avatar
    Join Date
    Dec 2004
    Posts
    114
    ive read my sams teach your self c++ in 24 hours cover to cover, and took a computer programming class and learned c++ for a small part of it, most of it was in JAVA. And if you are infering that I got the code from some where else your wrong, I wrote it my self!
    Last edited by Frantic-; 06-25-2005 at 09:58 PM.

  7. #7
    Registered User
    Join Date
    Jun 2005
    Posts
    6,434
    I wasn't inferring anything about whether you wrote your code or got it from somewhere else. I was simply noting that you experienced a problem that bites most beginners to C++ (and C), and what the solution is (which presumably you "got", although you didn't say it outright).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to solve warnings that appear when building my DLL...
    By starcatcher in forum Windows Programming
    Replies: 6
    Last Post: 12-14-2008, 10:47 AM
  2. non-MFC DLL with MFC app question.
    By Kempelen in forum Windows Programming
    Replies: 10
    Last Post: 08-20-2008, 07:11 AM
  3. building a DLL
    By sass in forum C++ Programming
    Replies: 1
    Last Post: 03-02-2006, 04:25 AM
  4. dll communicating between each other
    By cloudy in forum C++ Programming
    Replies: 5
    Last Post: 06-17-2005, 02:20 AM
  5. DLL and std::string woes!
    By Magos in forum C++ Programming
    Replies: 7
    Last Post: 09-08-2004, 12:34 PM

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