Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion samples/dclient.d
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ int dll_regserver(const (char) *dllname, int flag)
if (hMod)
{
printf("LoadLibraryA() %s\n", (flag ? "registered".ptr : "unregistered".ptr));
pfn = GetProcAddress(hMod, fn);
pfn = cast(pfn_t) GetProcAddress(hMod, fn);
printf("pfn = %p, fn = '%s'\n", pfn, fn);

if (pfn && SUCCEEDED((*pfn)()))
Expand Down
2 changes: 1 addition & 1 deletion samples/dhry.d
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ Boolean Func_3(Enumeration Enum_Par_Val)
return (false);
} /* Func_3 */

version (Win32)
version (Windows)
{
import core.sys.windows.windows;

Expand Down
2 changes: 1 addition & 1 deletion samples/dserver.d
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ BOOL SetKeyAndValue(LPCSTR pszKey, LPCSTR pszSubkey, LPCSTR pszValue)
if (null != pszValue)
{
if (RegSetValueExA(hKey, null, 0, REG_SZ, cast(BYTE *) pszValue,
(strlen(pszValue) + 1) * char.sizeof) != ERROR_SUCCESS)
cast(int)((strlen(pszValue) + 1) * char.sizeof)) != ERROR_SUCCESS)
result = false;
}

Expand Down
6 changes: 6 additions & 0 deletions samples/dserver64.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
EXPORTS
DllGetClassObject
DllCanUnloadNow
DllRegisterServer
DllUnregisterServer

28 changes: 15 additions & 13 deletions samples/htmlget.d
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
This code has no warranties and is provided 'as-is'.
*/

// debug = HTMLGET;
debug = HTMLGET;

import std.string, std.conv, std.stream, std.stdio;
import std.socket, std.socketstream;
import std.string, std.conv, std.stdio;
import std.socket;

int main(string[] args)
{
Expand Down Expand Up @@ -67,26 +67,34 @@ int main(string[] args)

Socket sock = new TcpSocket(new InternetAddress(domain, port));
scope(exit) sock.close();
Stream ss = new SocketStream(sock);

debug (HTMLGET)
writefln("Connected! Requesting URL \"%s\"...", url);

if (port != 80)
domain = domain ~ ":" ~ to!string(port);

ss.writeString("GET " ~ url ~ " HTTP/1.0\r\n"
"Host: " ~ domain ~ "\r\n"
sock.send("GET " ~ url ~ " HTTP/1.0\r\n" ~
"Host: " ~ domain ~ "\r\n" ~
"\r\n");

// Skip HTTP header.
while (true)
{
auto line = ss.readLine();
char[] line;
char[1] buf;
while(sock.receive(buf))
{
line ~= buf;
if (buf[0] == '\n')
break;
}

if (!line.length)
break;

write(line);

enum CONTENT_TYPE_NAME = "Content-Type: ";

if (line.length > CONTENT_TYPE_NAME.length &&
Expand All @@ -99,11 +107,5 @@ int main(string[] args)
}
}

while (!ss.eof())
{
auto line = ss.readLine();
writeln(line);
}

return 0;
}
69 changes: 69 additions & 0 deletions samples/win32.mak
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
MODEL=32
DMD=..\..\windows\bin\dmd
DFLAGS=-m$(MODEL)

EXAMPLES = hello d2html dhry pi sieve wc wc2 \
winsamp dserver$(MODEL) mydll htmlget listener

all: $(EXAMPLES)
echo done

d2html:
$(DMD) d2html $(DFLAGS)
.\d2html.exe d2html.d

dhry:
$(DMD) dhry $(DFLAGS)
.\dhry.exe

hello:
$(DMD) hello $(DFLAGS)
.\hello.exe

htmlget:
$(DMD) htmlget $(DFLAGS)
.\htmlget.exe www.dlang.org/index.html

listener:
$(DMD) listener $(DFLAGS)
# .\listener.exe

pi:
$(DMD) pi $(DFLAGS)
.\pi.exe 1000

sieve:
$(DMD) sieve $(DFLAGS)
.\sieve.exe

wc:
$(DMD) wc $(DFLAGS)
.\wc.exe wc.d

wc2:
$(DMD) wc2 $(DFLAGS)
.\wc2.exe wc2.d

winsamp:
$(DMD) winsamp $(DFLAGS) gdi32.lib user32.lib winsamp.def
# .\winsamp.exe

# COM client/server example
# dclient will fail unless run with administrator rights
dserver32:
$(DMD) dserver.d chello.d $(DFLAGS) dserver.def advapi32.lib ole32.lib user32.lib
$(DMD) dclient $(DFLAGS) ole32.lib uuid.lib
.\dclient.exe

dserver64:
$(DMD) dserver.d chello.d $(DFLAGS) -L/DLL dserver64.def advapi32.lib ole32.lib user32.lib
$(DMD) dclient $(DFLAGS) ole32.lib uuid.lib
.\dclient.exe

mydll:
$(DMD) $(DFLAGS) -ofmydll.dll -L/IMPLIB mydll\mydll.d mydll\dll.d mydll\mydll.def
$(DMD) $(DFLAGS) -ofdlltest.exe -Imydll mydll\test.d mydll.lib
.\dlltest.exe

clean:
clean.bat
4 changes: 4 additions & 0 deletions win32.mak
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ auto-tester-test:
cd test
$(MAKE)
cd ..
cd samples
gmake -f win32.mak DMD=..\src\dmd.exe MODEL=$(MODEL) "LIB=..\..\phobos;$(LIB)" \
"DFLAGS=-I..\..\druntime\import -I..\..\phobos -m$(MODEL)"
cd ..