Thread: DLL issue

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    For reference for others:
    Code:
    #include "stdafx.h"
    #include <stdio.h> // for namespace
    #include <valarray> // for Xor 
    #include <string>
    
    BOOL APIENTRY DllMain( HANDLE hModule, 
    					  DWORD ul_reason_for_call, 
    					  LPVOID lpReserved
    					  )
    {
    	return TRUE;
    }
    
    char outvalue[2] = "";
    char out [2] = "";
    
    __declspec(dllexport) LPCTSTR ecc(LPCTSTR invalue)
    {
    	unsigned int v=0;
    	unsigned int vlen=0;
    
    	// Setup Values of Variables 
    	vlen = strlen(invalue);
    	outvalue[0] = invalue[0];
    
    	// Loop
    	for(v;v<vlen-1;v++)
    	{ 
    		outvalue [0] ^= invalue[v+1]; 
    	}
    	sprintf(out, "&#37;X",2, outvalue[0]);
    
    	return out;
    }
    As a first suggestion, I'd like to advise to get rid of LPCTSTR and the like. In your functions, use appropriate type.
    The function should take const char* and return char*. OK? Good.
    Then you will need to allocate a buffer large enough to hold the new data via new.
    Then you simply assign the XORed data to your new buffer and return it.

    Start with that.
    Last edited by Elysia; 04-02-2008 at 12:15 PM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DLL Load issue
    By George2 in forum Windows Programming
    Replies: 2
    Last Post: 09-01-2007, 03:42 PM
  2. dll issue
    By axr0284 in forum C++ Programming
    Replies: 1
    Last Post: 03-23-2006, 08:37 AM
  3. dll communicating between each other
    By cloudy in forum C++ Programming
    Replies: 5
    Last Post: 06-17-2005, 02:20 AM
  4. dll : design issue!
    By dug in forum C++ Programming
    Replies: 8
    Last Post: 02-17-2005, 11:48 AM
  5. DLL and std::string woes!
    By Magos in forum C++ Programming
    Replies: 7
    Last Post: 09-08-2004, 12:34 PM