// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <windows.h>

#include <cstring>

using namespace std;

#using <mscorlib.dll>
#using <low2.dll>

using namespace System;
using namespace System::Runtime::InteropServices;

extern "C"
{
__declspec(dllexport) char* __stdcall dup(char* s);
}

static char buf[100];

__declspec(dllexport) char* __stdcall dup(char* s)
{
    String^ s2 = gcnew String(s);
    s2 = Low::Dup(s2);
    strcpy(buf, (char *)Marshal::StringToHGlobalAnsi(s2).ToPointer());
    return buf;
}
