You are on page 1of 2

#include "apdefap.

h"
void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char*
lpszPropertyName, UINT nFlags, int x, int y)
{
// WINCC:TAGNAME_SECTION_START
// syntax: #define TagNameInAction "DMTagName"
// next TagID : 1
// WINCC:TAGNAME_SECTION_END

// WINCC:PICNAME_SECTION_START
// syntax: #define PicNameInAction "PictureName"
// next PicID : 1
// WINCC:PICNAME_SECTION_END
#pragma code ("winmm.dll")
BOOL PlaySound(LPCSTR pszSound,HMODULE hMod,DWORD fdwSound);
#define SND_FILENAME 0x00020000L
#define SND_ASYNC 0x0001
#pragma code ()

char szProjectName[MAX_PATH];
CMN_ERROR Error;
char szSoundFilePath[MAX_PATH] = "";
char szSoundFile[MAX_PATH] = "EKNM.wav";

int iResult;

//get current language


switch (GetLanguage())
{
//set message text
//german
case 0x407: iResult=MessageBox(NULL,
"Wollen Sie Ihre Arbeit mit Project_WinCCEditors\r\n"
"wirklich beenden?\r\n",
"Runtime beenden",
MB_OKCANCEL|MB_ICONQUESTION|MB_SETFOREGROUND|MB_SYSTEMMODAL);
break;
//english
case 0x409: iResult=MessageBox(NULL,
"This ends your work with WinCC Runtime.\r\n",
"Shutdown Runtime",
MB_OKCANCEL|MB_ICONQUESTION|MB_SETFOREGROUND|MB_SYSTEMMODAL);
break;
//french
case 0x40C: iResult=MessageBox(NULL,
"Voulez-vous vraiment terminer votre\r\n"
"travail sur Project_WinCCEditors?\r\n",
"Terminer runtime",
MB_OKCANCEL|MB_ICONQUESTION|MB_SETFOREGROUND|MB_SYSTEMMODAL);
break;
}//switch

if (iResult==IDOK) {
//DeactivateRTProject();
//DMExitWinCCEx (DM_SDMODE_SYSTEM);
DeactivateRTProject ();
PlaySound(NULL,NULL,SND_FILENAME|SND_ASYNC);
}
}

Sub Write2TextFile

Option Explicit
Dim objFSO, objFolder, objShell, objTextFile, objFile
Dim strDirectory, strFile, strText
strDirectory = "D:\HngBatchHouse\Reports"
strFile = "\BATCHREPORT.TXT"
strText = "Book Another Holiday"

' Create the File System Object


Set objFSO = CreateObject("Scripting.FileSystemObject")

' Check that the strDirectory folder exists


If objFSO.FolderExists(strDirectory) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFolder = objFSO.CreateFolder(strDirectory)
WScript.Echo "Just created " & strDirectory
End If

If objFSO.FileExists(strDirectory & strFile) Then


Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFile = objFSO.CreateTextFile(strDirectory & strFile)
Wscript.Echo "Just created " & strDirectory & strFile
End If

set objFile = nothing


set objFolder = nothing
' OpenTextFile Method needs a Const value
' ForAppending = 8 ForReading = 1, ForWriting = 2
Const ForAppending = 8

Set objTextFile = objFSO.OpenTextFile _


(strDirectory & strFile, ForAppending, True)

' Writes strText every time you run this VBScript


objTextFile.WriteLine(strText)
objTextFile.Close

' Bonus or cosmetic section to launch explorer to check file


If err.number = vbEmpty then
Set objShell = CreateObject("WScript.Shell")
objShell.run ("Explorer" &" " & strDirectory & "\" )
Else WScript.echo "VBScript Error: " & err.number
End If

WScript.Quit

End Sub

You might also like