Polyglot: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
(→C/C++: Added single define) |
(Added C# and Inf) |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
[[Category:Code Examples]] | [[Category:Code Examples]] | ||
== Batch (NT) == | |||
<highlight-nsis> | |||
/*>nul 2>&1&@echo off&rem Note that this line will be visible when executed | |||
echo Hello World | |||
goto :EOF &rem */ | |||
Page InstFiles | |||
Section | |||
DetailPrint "Hello World" | |||
SectionEnd | |||
</highlight-nsis> | |||
== C/C++ == | == C/C++ == | ||
| Line 5: | Line 19: | ||
<highlight-nsis> | <highlight-nsis> | ||
#define /* | #define /* | ||
!define /**/ | !define /**/ MYNUMBER 1234 | ||
</highlight-nsis> | </highlight-nsis> | ||
| Line 16: | Line 29: | ||
Section | Section | ||
DetailPrint "Hello World" | |||
SectionEnd | SectionEnd | ||
!if 0 | !if 0 | ||
| Line 21: | Line 35: | ||
#include <stdio.h> | #include <stdio.h> | ||
int main() | |||
{ | { | ||
printf("Hello World\n"); | return !printf("Hello World\n"); | ||
} | } | ||
#if 0 | #if 0 | ||
| Line 29: | Line 43: | ||
#endif | #endif | ||
#endif //~ EOF */ | #endif //~ EOF */ | ||
</highlight-nsis> | |||
== C# == | |||
<highlight-nsis> | |||
#if NSIS | |||
Page InstFiles | |||
Section | |||
DetailPrint "Hello World" | |||
SectionEnd | |||
!if 0 | |||
#elif !NSIS | |||
using System; | |||
class TestApp { | |||
public static void Main() | |||
{ | |||
Console.WriteLine("Hello World"); | |||
} | |||
} | |||
#else | |||
!endif | |||
#endif | |||
</highlight-nsis> | |||
== Inf == | |||
<highlight-nsis> | |||
/* | |||
[Version] | |||
Signature=$CHICAGO$ | |||
[DefaultInstall] | |||
AddReg=AddReg | |||
[AddReg] | |||
HKLM,Software\Test,,,"Hello World" | |||
[Strings] | |||
[EOF] | |||
*/ | |||
Page InstFiles | |||
Section | |||
DetailPrint "Hello World" | |||
SectionEnd | |||
</highlight-nsis> | </highlight-nsis> | ||
Latest revision as of 18:15, 21 September 2025
Batch (NT)
/*>nul 2>&1&@echo off&rem Note that this line will be visible when executed echo Hello World goto :EOF &rem */ Page InstFiles Section DetailPrint "Hello World" SectionEnd
C/C++
#define /* !define /**/ MYNUMBER 1234
#if 0 /* NSIS */ Page InstFiles Section DetailPrint "Hello World" SectionEnd !if 0 #else /* C */ #include <stdio.h> int main() { return !printf("Hello World\n"); } #if 0 !endif #endif #endif //~ EOF */
C#
#if NSIS Page InstFiles Section DetailPrint "Hello World" SectionEnd !if 0 #elif !NSIS using System; class TestApp { public static void Main() { Console.WriteLine("Hello World"); } } #else !endif #endif
Inf
/* [Version] Signature=$CHICAGO$ [DefaultInstall] AddReg=AddReg [AddReg] HKLM,Software\Test,,,"Hello World" [Strings] [EOF] */ Page InstFiles Section DetailPrint "Hello World" SectionEnd