Polyglot: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (→‎C/C++: Simplify)
(Added C# and Inf)
 
(One intermediate revision 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 15: Line 29:


Section
Section
  DetailPrint "Hello World"
SectionEnd
SectionEnd
!if 0
!if 0
Line 20: Line 35:
#include <stdio.h>
#include <stdio.h>


void main()
int main()
{
{
   printf("Hello World\n");
   return !printf("Hello World\n");
}
}
#if 0
#if 0
Line 28: 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