Primer
WEB program development has made great challenges for development tools. Many companies have introduced a lot of development platforms for many companies: developing desktop applications and C / S procedures, developing a web server. This causes programmers to face a lot of tools.
Delphi and other development tools are different because it is an open system, as long as you use some controls, you can develop various types of systems, regardless of the N-TIE program, multi-threaded programs, distribution computing programs, including DCOM, and CORBARs. TCP program, web program, ActiveX, middleware, push program (PUSH), and even you can use it to write assemblers.
Delphi cleverly encapsulates ISAPI / NSAPI / CGI / WCGI, etc., users can get different systems as long as they choose to compile results at compile time.
Inprise in Delphi4 further strengthens support for web program development, you can develop a better system. The following is a few common problems in the development of web applications, you can use your reference. If there is no special declaration, the program is running under Delphi 4.
How do I return an image from the web server application?
Web Server Applications not only generates complex page documents, but also different images are returned according to user requests. Of course, there is a relatively simple method, depending on the input parameters, tag also points to different URL addresses. Here we don't have this approach, but returns an image with DLL.
Of course, you must first create a page contucer (page product), as follows:
this is a testYou do not set drive path mappings corresponding to your IUSR_XXX account. Because Novell is not used by FAT, it is necessary to manually add a path mapping. Of course, you can make a boot login script. Keep in mind if you run the IIS as a web server, but also involve Novell, whether or not the path mapping is defined as a file server or database server.
"Invalid Configuration Parameter for alias {alias_name}", when I set an ODBC DSN and access it when accessing the ISAPI / NSAPI server, there is such an error.
If you want to create an ODBC alias for users (IIS users), you should pay attention to create a System DSN (System DNS) instead of creating "User DNS", although "user DNS" is default.
How to get the name and IP address of the client (access machine)?
It is very easy to achieve this function. Select a TCP control from the Internet page, then you can get what you need:
Memo1.Lines.Add (tcp1.localhostname);
Memo1.Lines.Add (TCP1.Localip);
Of course, if you don't want to do this, there is a complicated approach:
Uses winsock;
Procedure TFORM1.FormCreate (Sender: TOBJECT);
VAR
WVersionRequested: Word;
Wsadata: TWSADATA;
Begin
{Creating WinSock}
WVersionRequested: = MakeWord (1, 1);
WSASTARTUP (WVersionRequested, WSADATA);
END;
Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT);
VAR
p: phostent;
s: array [0..128] of char;
P2: pchar;
Begin
{Get the computer name}
Gethostname (@ s, 128);
p: = gethostbyname (@S);
Memo1.Lines.Add (p ^ .h_name);
{Get the machine IP address}
P2: = INET_NTOA (PINADDR (p ^ .h_addr_list ^);
Memo1.Lines.Add (p2);
END;
Procedure TFORM1.FORMDESTROY (Sender: TOBJECT); Begin
{Release Winsock}
WSACLEANUP;
END;
This is an independent unit called Winsock, you can embed it directly into your program.
Why can't Delphi 3 can't create a real multi-threaded DLL?
Although the ISAPI DLL wizard in Delphi3 has generated a large number of code for creating multi-threaded DLL, there is still a serious defect: no application of this application is a multi-threaded program. So you need you to add a sentence:
Ismultithread: = true;
Put this sentence on the beginning of the DPR program Begin-End block, make it the first sentence.
How do I know if I now connect with the Internet?
The easiest way is to use a TCP component to get your current IP, by judging whether IP knows whether it is connected to the Internet. E.g:
IF TCP1.LOCALIP = '0.0.0.0' Then
ShowMessage ('There is currently no access to Internet!');
It should be noted that because Internet and intranet have no essential difference, it is generally not determined to be connected to the Internet or just incorporate intranet. of course. You can also add a ping component, go to the job, a stable site, if the speed is relatively fast, if connected, indicates that the Internet has been accessed. However, this method is universal.
How do I print a web page?
The AutoPrint method of the HTML control can be used. E.g:
Uses printers;
Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT);
VAR
Oldcur: TCURSOR;
Begin
Oldcur: = Screen.cursor;
With printer do
Begin
Begindoc;
HTML1.AUTOPRINT (HANDLE);
Title: = html1.ur;
Enddoc;
END;
Screen.cursor: = Oldcur;
END;
It can also be utilized to use its PrintPage method. But I recommend you use AutoPrint, because this control is more flexible, you can filter some content you don't want to print.