The first to post here!

Discussion in 'I wanna be a Game Programmer' started by Mathematix, Dec 28, 2006.

  1. Mathematix

    Mathematix Banned

    Booyah! \:D/

    I guess this is for programming advice, so here goes:

    Code:
    #include <stdio.h>
    
    int main()
    {
        puts("I'm not saying Hello World, right!");
    
        return 0;
    }
    
    This code simply refuses to say 'Hello World!'. Why? :-k
     
  2. Mox

    Mox Gaming God One Of Us

    How does that qualify as advice?

    :p
     
  3. Mathematix

    Mathematix Banned

    Well... umm... I just dunno why it diesn't say what I want it to. :-k
     
  4. Chigley

    Chigley I yam what I yam. One Of Us

    Here you go. This should clear everything up for you ..

    Code:
    [ uuid(2573F8F4-CFEE-101A-9A9F-00AA00342820) ]
    library LHello
    {
    	// bring in the master library
    	importlib("actimp.tlb");
    	importlib("actexp.tlb");
    
    	// bring in my interfaces
    	#include "pshlo.idl"
    
    	[ uuid(2573F8F5-CFEE-101A-9A9F-00AA00342820) ]
    	cotype THello
    	{
    		interface IHello;
    		interface IPersistFile;
    	};
    };
    
    [ exe, uuid(2573F890-CFEE-101A-9A9F-00AA00342820) ]
    module CHelloLib
    {
    	// some code related header files
    	importheader(<windows.h>);
    	importheader([list=1]);
    	importheader(<except.hxx>);
    	importheader("pshlo.h");
    	importheader("shlo.hxx");
    	importheader("mycls.hxx");
    
    	// needed typelibs
    	importlib("actimp.tlb");
    	importlib("actexp.tlb");
    	importlib("thlo.tlb");
    
    	[ uuid(2573F891-CFEE-101A-9A9F-00AA00342820), aggregatable ]
    	coclass CHello
    	{
    		cotype THello;
    	};
    };
    
    #include "ipfix.hxx"
    
    extern HANDLE hEvent;
    
    class CHello : public CHelloBase
    {
    public:
    	IPFIX(CLSID_CHello);
    
    	CHello(IUnknown *pUnk);
    	~CHello();
    
    	HRESULT  __stdcall PrintSz(LPWSTR pwszString);
    private:
    	static int cObjRef;
    };
    
    #include <windows.h>
    #include [list=1]
    #include <stdio.h>
    #include <stdlib.h>
    #include "thlo.h"
    #include "pshlo.h"
    #include "shlo.hxx"
    #include "mycls.hxx"
    
    int CHello::cObjRef = 0;
    
    CHello::CHello(IUnknown *pUnk) : CHelloBase(pUnk)
    {
    	cObjRef++;
    	return;
    }
    
    HRESULT  __stdcall  CHello::PrintSz(LPWSTR pwszString)
    {
    	printf("%ws\n", pwszString);
    	return(ResultFromScode(S_OK));
    }
    
    CHello::~CHello(void)
    {
    	// when the object count goes to zero, stop the server
    	cObjRef--;
    	if( cObjRef == 0 )
    		PulseEvent(hEvent);
    	return;
    }
    
    #include <windows.h>
    #include [list=1]
    #include "pshlo.h"
    #include "shlo.hxx"
    #include "mycls.hxx"
    
    HANDLE hEvent;
    
    int _cdecl main( int argc, char * argv[] )
    {
    	ULONG ulRef;
    	DWORD dwRegistration;
    	CHelloCF *pCF = new CHelloCF();
    
    	hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
    
    	// Initialize the OLE libraries
    	CoInitializeEx(NULL, COINIT_MULTITHREADED);
    	
    	CoRegisterClassObject(CLSID_CHello, pCF, CLSCTX_LOCAL_SERVER,
    	REGCLS_MULTIPLEUSE, &dwRegistration);
    	
    	// wait on an event to stop
    	WaitForSingleObject(hEvent, INFINITE);
    	
    	// revoke and release the class object
    	CoRevokeClassObject(dwRegistration);
    	ulRef = pCF->Release();
    	
    	// Tell OLE we are going away.
    	CoUninitialize();
    	
    	return(0);
    }
    
    extern CLSID CLSID_CHello;
    extern UUID LIBID_CHelloLib;
    
    CLSID CLSID_CHello = { /* 2573F891-CFEE-101A-9A9F-00AA00342820 */
    0x2573F891, 0xCFEE, 0x101A, { 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 } };
    
    UUID LIBID_CHelloLib = { /* 2573F890-CFEE-101A-9A9F-00AA00342820 */
    0x2573F890, 0xCFEE, 0x101A, { 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 } };
    
    #include <windows.h>
    #include [list=1]
    #include <stdlib.h>
    #include <string.h>
    #include <stdio.h>
    #include "pshlo.h"
    #include "shlo.hxx"
    #include "clsid.h"
    
    int _cdecl main( int argc, char * argv[] )
    {
    	HRESULT  hRslt;
    	IHello *pHello;
    	ULONG  ulCnt;
    	IMoniker * pmk;
    	WCHAR  wcsT[_MAX_PATH];
    	WCHAR  wcsPath[2 * _MAX_PATH];
    
    	// get object path
    	wcsPath[0] = '\0';
    	wcsT[0] = '\0';
    	if( argc  1) {
    		mbstowcs(wcsPath, argv[1], strlen(argv[1]) + 1);
    		wcsupr(wcsPath);
    	}
    	else
    	{
    	fprintf(stderr, "Object path must be specified\n");
    	return(1);
    	}
    
    	// get print string
    	if(argc  2)
    		mbstowcs(wcsT, argv[2], strlen(argv[2]) + 1);
    	else
    		wcscpy(wcsT, L"Hello World");
    
    	printf("Linking to object %ws\n", wcsPath);
    	printf("Text String %ws\n", wcsT);
    
    	// Initialize the OLE libraries
    	hRslt = CoInitializeEx(NULL, COINIT_MULTITHREADED);
    
    	if(SUCCEEDED(hRslt))
    	{
    		hRslt = CreateFileMoniker(wcsPath, &pmk);
    		if(SUCCEEDED(hRslt))
     			hRslt = BindMoniker(pmk, 0, IID_IHello, (void **)&pHello);
    		if(SUCCEEDED(hRslt))
    		{
    			// print a string out
    		 	pHello->PrintSz(wcsT);
    
    			Sleep(2000);
    			ulCnt = pHello->Release();
    		}
    		else
    			printf("Failure to connect, status: %lx", hRslt);
    	
    		// Tell OLE we are going away.
    		CoUninitialize();
    	}
    		
    	return(0);
    }
    
    NOTE: Not mine.
     
  5. phroztee

    phroztee Gamer One Of Us


    I like it, but I think it needs the following additions:

    Code:
    HelloWorldObserver
    {
        ...
    }
    
    HelloWorldObserverFacade
    {
        ...
    }
    
    HelloWorldVisitor
    {
        ...
    }
    
    HelloWorldVisitorIterator
    {
        ...
    }
    
    HelloWorldProxy
    {
        ...
    }
    
    HelloWorldProxyDecorator
    {
        ...
    }
    
    HelloWorldFactory
    {
        ...
    }
    
    HelloWorldFactorySingleton
    {
        ...
    }
    
    Oh, and at least 42 conversions from a char* to a std::string and back again, just to shit all over the heap for good measure.
     
  6. Mathematix

    Mathematix Banned

    As clear as extra dirty mud with loads of flour thrown in! :shock:
     
  7. IFW

    IFW Not allowed to say NFTS are shit One Of Us

    Code:
    void main (void)
    {
       for (int i = 0; i < 100; i++)
       {
          switch (i)
          {
          case 0:
          case 1:
          case 2:
          case 3:
          case 4:
          case 5:
          case 6:
          case 7:
          case 8:
          case 9:
          case 10:
          case 11:
          case 12:
          case 13:
          case 14:
          case 15:
          case 16:
          case 17:
          case 18:
          case 19:
          case 20:
          case 21:
          case 22:
          case 23:
          case 24:
          case 25:
          case 26:
          case 27:
          case 28:
          case 29:
          case 30:
          case 31:
          case 32:
          case 33:
          case 34:
          case 35:
          case 36:
          case 37:
          case 38:
          case 39:
          case 40:
          case 41:
          case 42:
          case 43:
          case 44:
          case 45:
          case 46:
          case 47:
          case 48:
          case 49:
          case 50:
          case 51:
          case 52:
          case 53:
          case 54:
          case 55:
          case 56:
          case 57:
          case 58:
          case 59:
          case 60:
          case 61:
          case 62:
          case 63:
          case 64:
          case 65:
          case 66:
          case 67:
          case 68:
          case 69:
          case 70:
          case 71:
          case 72:
          case 73:
          case 74:
          case 75:
          case 76:
          case 77:
          case 78:
          case 79:
          case 80:
          case 81:
          case 82:
          case 83:
          case 84:
          case 85:
          case 86:
          case 87:
          case 88:
          case 89:
          case 90:
          case 91:
          case 92:
          case 93:
          case 94:
          case 95:
          case 96:
          case 97:
          case 98:
          case 99:
          break;
          default:
              printf("hello mum!! I cant count!");
          break;
          }
       }
    }
     
  8. IFW

    IFW Not allowed to say NFTS are shit One Of Us

    Well those are definately NOT saying "hello mum!"

    "hello world", maybe.. but not "hello mum"
     
  9. Mathematix

    Mathematix Banned

    I can't believe that you went through all that bother. You must have so much spare time, dude! :lol:
     
  10. baboon1972

    baboon1972 Troll One Of Us

    This should sort our your problem matey:

    10 print "I'm not saying Hello World, right!"
    20 goto 10

    Bringing it back to the old skool. Oh yeah.....



    :coat:
     
  11. Mathematix

    Mathematix Banned

    Won't compile for Visual C++ 2005. :-k
     
  12. yaustar

    yaustar Industry Professional One Of Us

    Code:
    HAI
    CAN HAS STDIO?
    VISIBLE "HAI WORLD!"
    KTHXBYE
    Done.
     
  13. kexik

    kexik Lurker One Of Us

    What language is used in post from Chigley? It looks like C++, but what about first part where are importheader keywords and #include
    1. ?