DateTime now = DateTime::Now;
Console::WriteLine(now.ToString(L"yyyy-MM-dd HH:mm:ss"));
#if _DEBUG
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#define new new(_NORMAL_BLOCK, __FILE__, __LINE__)
#endif
::_CrtSetDbgFlag(_CRTDBG_LEAK_CHECK_DF | _CRTDBG_ALLOC_MEM_DF);
typedef void (__stdcall *FUNC_SampleAPI)();
HINSTANCE hInst;
FUNC_SampleAPI SampleAPI;
hInst = ::LoadLibrary(L"SampleDLL");
SampleAPI = (FUNC_SampleAPI)::GetProcAddress(hInst, "SampleAPI");
SampleAPI();
::FreeLibrary(hInst);
const System::String^ path = System::IO::Path::GetDirectoryName(Application::StartupPath) + "\\";
System::Media::SoundPlayer^ soundPlayer = nullptr;
void StopSound(void) {
if (soundPlayer != nullptr) {
soundPlayer->Stop();
soundPlayer = nullptr;
}
}
void PlaySound(System::String^ fileName) {
if (soundPlayer != nullptr) {
StopSound();
}
soundPlayer = gcnew System::Media::SoundPlayer(path + fileName);
soundPlayer->Play();
}
PlaySound("SAMPLE.WAV");
System::String^ sampleString = gcnew System::String("Sample String");
char* pString = (char*)System::Runtime::InteropServices::Marshal::StringToHGlobalAnsi(sampleString).ToPointer();
// do something
System::Runtime::InteropServices::Marshal::FreeHGlobal(IntPtr(pString));