‚b‚n‚l ƒvƒƒOƒ‰ƒ~ƒ“ƒO‚Q - ƒtƒ@ƒCƒ‹‚̃Aƒbƒvƒ[ƒh

HTML‚©‚ç‚̃tƒ@ƒCƒ‹‚̃Aƒbƒvƒ[ƒh‚ðƒTƒ|[ƒg‚·‚éCOMƒvƒƒOƒ‰ƒ€‚ðì¬‚µ‚Ü‚·B ŽŸ‚̃ƒ\ƒbƒh‚ðŽÀ‘•‚µ‚Ä‚Ý‚Ü‚µ‚傤B
œSaveAs ....... ƒtƒ@ƒCƒ‹‚ð•Û‘¶
œFormData ..... ƒtƒH[ƒ€‚ÌTEXT‚Ȃǂ̃^ƒO‚ð•Ô‚·
œFileName ..... ƒtƒ@ƒCƒ‹–¼‚ð•Ô‚·
1999/04/12XVB
=================== fup.html ================
<HTML><BODY>
<FORM ACTION="fup.asp"  ENCTYPE="multipart/form-data" METHOD=POST>
Ž–¼: <INPUT TYPE=TEXT NAME="yourname"><BR>
ƒtƒ@ƒCƒ‹‚P: <INPUT TYPE=file NAME="file1"><BR>
ƒtƒ@ƒCƒ‹‚Q: <INPUT TYPE=file NAME="file2"><BR>
<INPUT TYPE=SUBMIT NAME=UPLOAD>
</FORM></BODY></HTML>
=================== fup.html end ============

=================== fup.asp =================
<%
set obj=server.createobject("fileup")
name=obj.FormData("yourname")
f1=obj.FileName("file1")
newf1="d:\temp\fup" & Mid(f1,InstrRev(f1,"\"))
fsize1=obj.SaveAs("file1",newf1)
%>
<HTML><HEAD><TITLE>File Upload Test</TITLE>
<BODY>
<H1>Testing</H1>
<BR>
<%= name %>‚³‚ñA<%= newf1 %>‚ɃAƒbƒvƒ[ƒh‚³‚ê‚Ü‚µ‚½<BR>
ƒtƒ@ƒCƒ‹ƒTƒCƒY= <%= fsize1 %><BR>
=================== fup.asp end =============
‚±‚±‚Å‚ÍŽŸ‚Ì‚±‚Æ‚ªŠwK‚Å‚«‚Ü‚·B

ATL COM AppWizardƒvƒƒWƒFƒNƒg‚̍쐬

[ƒtƒ@ƒCƒ‹]-[V‹Kì¬]‚Å[ƒvƒƒWƒFƒNƒg]ƒy[ƒW‚Ì[ATL COM AppWizard]‚ð ‘I‘ð‚µ‚Ä[OK]‚ð‰Ÿ‚µ‚Ü‚·BŽŸ‚ðƒ`ƒFƒbƒN‚µ‚Ä[I—¹]‚ð‰Ÿ‚µ‚Ü‚·B

ATLƒIƒuƒWƒFƒNƒg‚̐V‹Kì¬

[‘}“ü]-[ATLƒIƒuƒWƒFƒNƒg‚̐V‹Kì¬]‚Å[ATLƒIƒuƒWƒFƒNƒg ƒEƒBƒU[ƒh]ƒ_ƒCƒAƒƒO‚ð ŠJ‚«‚Ü‚·B

ƒNƒ‰ƒCƒAƒ“ƒg‚©‚çƒf[ƒ^‚ðŽóŽæ‚é‚Ì‚ÉIRequestƒCƒ“ƒ^ƒtƒF[ƒX‚ðŽg‚¤‚̂ŁA [ActiveXƒT[ƒoƒRƒ“ƒ|[ƒlƒ“ƒg]‚ðƒNƒŠƒbƒN‚µ‚Ä‘I‘ð‚µ‚ÄA[ŽŸ‚Ö]‚ð‰Ÿ‚µ‚Ü‚·B

[ATL Object Wizard‚̃vƒƒpƒeƒB]ƒ_ƒCƒAƒƒO‚ªŠJ‚«‚Ü‚·B
[–¼‘O]ƒy[ƒW‚Ì[C++ ƒVƒ‡[ƒg]‚É–¼‘O‚ð“ü‚ê‚é‚ÆŽ©“®“I‚É ‚·‚ׂẴeƒLƒXƒgƒ{ƒbƒNƒX‚ɃfƒtƒHƒ‹ƒg‚Ì–¼‘O‚ª“ü‚è‚Ü‚·B
.H ƒtƒ@ƒCƒ‹‚Æ.CPPƒtƒ@ƒCƒ‹‚Ì–¼‘O‚ÆProg ID‚Ì–¼‘O‚ð•ÏX‚µ‚Ü‚·B

[Prog ID]‚ªŠO•”‚©‚炱‚̃Rƒ“ƒ|[ƒlƒ“ƒg‚ðƒAƒNƒZƒX‚·‚é‚Æ‚«‚ÉŽw’è‚·‚é–¼‘O‚Æ‚È‚è‚Ü‚·B ASP‚ÌVBScript‚ÌServer.CreateObjectƒƒ\ƒbƒh‚ŃIƒuƒWƒFƒNƒg‚ðì¬‚·‚é‚Æ‚«‚ÉŽg‚¢‚Ü‚·B ‚±‚Ì—á‚ł́ASet obj = Server.CreateObject("FileUp")‚É‚È‚è‚Ü‚·B
[‘®«]ƒy[ƒW‚Å‚ÍŽŸ‚ðƒ`ƒFƒbƒN‚µ‚Ü‚·B


[ASP]ƒy[ƒW‚Å‚ÍŽŸ‚ðƒ`ƒFƒbƒN‚µ‚Ü‚·B—v‹‚Æ‚ÍASP‚ÌIRequestƒIƒuƒWƒFƒNƒg‚Ì‚±‚Æ‚Å‚·B


ƒCƒ“ƒ^ƒtƒF[ƒX‚Ƀƒ\ƒbƒh‚ð’ljÁ

ƒNƒ‰ƒXƒrƒ…[‚Ì’†‚̃Cƒ“ƒ^ƒtƒF[ƒXi‚±‚±‚Å‚Í IFileUp )‚ð‰EƒNƒŠƒbƒN‚µ‚Ä [ƒƒ\ƒbƒh‚̒ljÁ]‚ð‘I‘ð‚µ‚Ü‚·B

SaveAsƒƒ\ƒbƒh‚ðŽŸ‚Ì‚æ‚¤‚ÉŽw’肵‚Ü‚·B [in] BSTR name,[in] BSTR fpath,[out,retval] long *pVal



“¯‚¶‚悤‚ÉŽŸ‚̃ƒ\ƒbƒh‚à’ljÁ‚µ‚Ü‚·B
FormData [in] BSTR name,[out,retval] BSTR *pVal
FileName [in] BSTR fname,[out,retval] BSTR *pVal

ƒƒ\ƒbƒh‚̃Cƒ“ƒvƒŠƒƒ“ƒg

1. ƒ\[ƒXƒR[ƒh‚ðƒ_ƒEƒ“ƒ[ƒh fileup.lzh
‰ð“€‚µ‚½ŽŸ‚̃tƒ@ƒCƒ‹‚ðƒvƒƒWƒFƒNƒg‚̃fƒBƒŒƒNƒgƒŠ‚ɃRƒs[‚µ‚Ü‚·B
fileupx.cpp (’uŠ·‚µ‚Ü‚·)
fileupx.h  (’uŠ·‚µ‚Ü‚·)
brfc1867.h
brfc1867.cpp
‚»‚Ì‘¼‚·‚ׂẴvƒƒWƒFƒNƒgƒtƒ@ƒCƒ‹‚ªŠÜ‚Ü‚ê‚Ä‚Ü‚·‚ªƒRƒs[‚·‚é‚̂́A
ã‚Ì‚S‚‚̃tƒ@ƒCƒ‹‚¾‚¯‚É‚µ‚Ü‚·B

=========================================================================
‚·‚®ŽŽ‚µ‚½‚¢l‚âŽè‡‚Ç‚¨‚è‚â‚Á‚Ä‚à‚¤‚Ü‚­‚¢‚©‚È‚¢ê‡‚́A
‰ð“€‚µ‚½‘S‚Ẵtƒ@ƒCƒ‹‚ðfileupƒfƒBƒŒƒNƒgƒŠ‚ɃRƒs[‚µ‚Ä
fileup.dsw‚ðƒNƒŠƒbƒN‚·‚ê‚΃vƒƒWƒFƒNƒg‚ªŠJ‚«‚Ü‚·‚Ì‚Å‚·‚®ƒrƒ‹ƒh‚Å‚«‚Ü‚·B
’A‚µA‚±‚Ìfileup.dswƒtƒ@ƒCƒ‹‚ÍVisual C++ 6.0‘Ήž‚Å‚·B
Visual C++ 5.0‚ł̓rƒ‹ƒh‚Å‚«‚Ü‚¹‚ñB
=========================================================================


2. ƒvƒƒWƒFƒNƒg‚Ƀtƒ@ƒCƒ‹‚ð’ljÁ
[ƒvƒƒWƒFƒNƒg]-[ƒvƒƒWƒFƒNƒg‚ɒljÁ]-[ƒtƒ@ƒCƒ‹]‚ŒljÁ‚µ‚Ü‚·B brfc1867.h brfc1867.cpp 3. Fileupx.cppƒtƒ@ƒCƒ‹
FileUpx.cpp‚́AŽŸ‚̂悤‚É‚È‚è‚Ü‚·B // FileUpx.cpp : CFileUp ‚̃Cƒ“ƒvƒŠƒƒ“ƒe[ƒVƒ‡ƒ“ #include "stdafx.h" #include "FileUp.h" #include "FileUpx.h" ///////////////////////////////////////////////////////////////////////////// // CFileUp STDMETHODIMP CFileUp::OnStartPage (IUnknown* pUnk) { if(!pUnk) return E_POINTER; CComPtr<IScriptingContext> spContext; HRESULT hr; // IScriptingContext ƒCƒ“ƒ^[ƒtƒFƒCƒX‚̎擾 hr = pUnk->QueryInterface(IID_IScriptingContext, (void **)&spContext); if(FAILED(hr)) return hr; // Request ƒIƒuƒWƒFƒNƒg‚̃|ƒCƒ“ƒ^‚ðŽæ“¾ hr = spContext->get_Request(&m_piRequest); if(FAILED(hr)) { spContext.Release(); return hr; } // ƒAƒbƒvƒ[ƒhƒf[ƒ^‚ðRequest.BinaryRead‚Å•Û‘¶ m_rfc1867.Open(m_piRequest); m_bOnStartPageCalled = TRUE; return S_OK; } STDMETHODIMP CFileUp::OnEndPage () { m_rfc1867.Close(); // ƒoƒbƒtƒ@‚ðŠJ•ú m_bOnStartPageCalled = FALSE; // ‚·‚ׂẴCƒ“ƒ^[ƒtƒFƒCƒX‚ð‰ð•ú‚µ‚Ü‚· m_piRequest.Release(); return S_OK; } STDMETHODIMP CFileUp::SaveAs(BSTR name, BSTR fpath, long *pVal) { USES_CONVERSION; LPCSTR szName = OLE2T(name); LPCSTR szFileName = OLE2T(fpath); int flen; char *tf = m_rfc1867.FileData(szName,&flen); if(tf == NULL || flen < 1) { *pVal = -2; return S_OK; } HANDLE hFile = CreateFile((const char*)szFileName, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if(hFile == INVALID_HANDLE_VALUE) { *pVal = -3; return S_OK; } DWORD dwAmt; if(!WriteFile(hFile, tf, flen, &dwAmt, NULL)) { CloseHandle(hFile); *pVal = -4; return S_OK; } CloseHandle(hFile); *pVal = dwAmt; return S_OK; } STDMETHODIMP CFileUp::FormData(BSTR fname, BSTR *pVal) { USES_CONVERSION; LPCSTR szName = OLE2T(fname); int dlen; char *name = m_rfc1867.FormData(szName,&dlen); if(name == NULL) { *pVal = A2BSTR(""); return S_OK; } int mlen = dlen + 4096; char *tp = new char[mlen]; if (tp == NULL) { delete [] name; return ResultFromScode(E_OUTOFMEMORY); } memcpy(tp,name,dlen); tp[dlen] = 0; int clen = dlen; delete [] name; name = m_rfc1867.FormData(szName,&dlen); while (name) { tp[clen++] = '\t'; if (mlen < (clen + dlen + 1)) { char *tp2 = new char[mlen+dlen + 4096]; if (tp2 == NULL) { delete [] tp; delete [] name; return ResultFromScode(E_OUTOFMEMORY); } memcpy(tp2,tp,clen); delete [] tp; tp = tp2; mlen += dlen + 4096; } memcpy(tp+clen,name,dlen); clen += dlen; tp[clen] = 0; delete [] name; name = m_rfc1867.FormData(szName,&dlen); } *pVal = A2BSTR(tp); delete [] tp; return S_OK; } STDMETHODIMP CFileUp::FileName(BSTR fname, BSTR *pVal) { USES_CONVERSION; LPCSTR szName = OLE2T(fname); char *name = m_rfc1867.FileName(szName); if(name == NULL) { *pVal = A2BSTR(""); return S_OK; } *pVal = A2BSTR(name); delete [] name; return S_OK; }

ƒfƒoƒbƒO‚Ì•û–@

1. ƒfƒoƒbƒOƒ‚[ƒh‚Ńrƒ‹ƒh
2. [ƒrƒ‹ƒh] ƒƒjƒ…[ [ƒfƒoƒbƒO‚ÌŠJŽn] ‚Ì [ƒvƒƒZƒX‚ÖƒAƒ^ƒbƒ`] ‚ð‘I‘ð
3. [ƒvƒƒZƒX‚ÖƒAƒ^ƒbƒ`vƒEƒBƒ“ƒhƒE‚Å [ƒVƒXƒeƒ€ ƒvƒƒZƒX‚ð•\Ž¦] ‚ðƒ`ƒFƒbƒN‚·‚é‚ƁA inetinfo.exe‚ª•\Ž¦‚³‚ê‚é‚̂ŁA‘I‘ð‚µ‚Ä OK ƒ{ƒ^ƒ“
4. [ƒvƒƒWƒFƒNƒg]-[Ý’è]‚Å[ƒfƒoƒbƒO]-[ƒJƒeƒSƒŠ]-[’ljÁ‚·‚éDLL]‚Å debugƒfƒBƒŒƒNƒgƒŠ‚ÌFileup.dll‚ð‘I‘ðB ‚±‚ê‚ð–Y‚ê‚é‚ƃuƒŒ[ƒNƒ|ƒCƒ“ƒg‚ªÝ’è‚Å‚«‚È‚¢B
5. [ƒtƒ@ƒCƒ‹] ƒƒjƒ…[‚Ì [ŠJ‚­] ‚ð‘I‘ð‚µAFileupx.cppƒ\[ƒXƒtƒ@ƒCƒ‹‚ðŠJ‚­
6. ƒ\[ƒXƒtƒ@ƒCƒ‹‚ɃuƒŒ[ƒNƒ|ƒCƒ“ƒg(F9‚ð‰Ÿ‚·)‚ðÝ’è
7. ƒuƒ‰ƒEƒU‚©‚çFileUpƒRƒ“ƒ|[ƒlƒ“ƒg‚ðŒÄ‚яo‚·.asp‚ð•\Ž¦
8. Good luck!

Release Mindependency‚ł̃rƒ‹ƒh

”z•z‚Ì‚½‚ß‚É[ƒrƒ‹ƒh]-[ƒAƒNƒeƒBƒu‚ȍ\¬‚̐ݒè]‚ÅRelease Mindependency‚ð‘I‘ð‚µ‚Äƒrƒ‹ƒh‚µ‚Ü‚·B ƒŠƒ“ƒNŽž‚ÉŽŸ‚̃Gƒ‰[‚ª”­¶‚µ‚Ü‚·B

LIBCMT.lib(crt0.obj) : error LNK2001: ŠO•”¼ÝÎÞÙ "_main" ‚Í–¢‰ðŒˆ‚Å‚·
ReleaseMinDependency/FileUp.dll : fatal error LNK1120: ŠO•”ŽQÆ 1 ‚ª–¢‰ðŒˆ‚Å‚·B
link.exe ‚ÌŽÀs´×°

FileUp.dll - ´×° 2AŒx 0

‚±‚̃Gƒ‰[‚́ACƒ‰ƒ“ƒ^ƒCƒ€ŠÖ”‚ªƒŠƒ“ƒN‚³‚ê‚Ä‚¢‚È‚¢‚Æ‚«‚É”­¶‚µ‚Ü‚·B
C‚̃‰ƒ“ƒ^ƒCƒ€ŠÖ”‚ðƒvƒƒWƒFƒNƒg“à‚ÅŽg‚Á‚Ä‚¢‚é‚Æ”­¶‚µ‚Ü‚·B
Releaseƒrƒ‹ƒh‚̃fƒtƒHƒ‹ƒg‚Å‚ÍATL COM AppWizard‚́ACƒ‰ƒ“ƒ^ƒCƒ€‚ðƒŠƒ“ƒN‚µ‚Ü‚¹‚ñB
‚±‚ê‚́A_ATL_MIN_CRTƒvƒŠƒvƒƒZƒbƒT•¶Žš‚ªŽw’肳‚ê‚Ä‚¢‚邽‚ß‚Å‚·B
‘΍ô‚Æ‚µ‚ẮF
œ[ƒvƒƒWƒFƒNƒg‚̐ݒè] -[C/C++]-[ƒvƒŠƒvƒƒZƒbƒT‚Ì’è‹`]‚Å_ATL_MIN_CRT‚ðíœ
‚±‚¤‚·‚é‚ÆC‚̃‰ƒ“ƒ^ƒCƒ€‚ªƒŠƒ“ƒN‚³‚ê‚ăGƒ‰[‚ªÁ‚¦‚Ü‚·B
‚±‚ꂾ‚¯‚Å‚n‚j‚Å‚·B
‚à‚¤ˆê‚‚̕û–@‚́F
œC‚̃‰ƒ“ƒ^ƒCƒ€ŠÖ”‚ðŽg‚¤‚Ì‚ð‚â‚ß‚é
strlen ‚Ȃǂ̊֐”‚ð lstrlen ‚ȂǂɕύX‚µ‚Ü‚·B

¡‰ñ‚́A_ATL_MIN_CRT‚Í‚»‚Ì‚Ü‚Ü‚É‚µ‚āAC‚̃‰ƒ“ƒ^ƒCƒ€ŠÖ”‚ðŽg‚¤‚Ì‚ð‚â‚ß‚Ä
‚±‚Ì–â‘è‚ɑΏˆ‚µ‚Ü‚·B
brfc1867.cpp ƒtƒ@ƒCƒ‹‚ÌstrnicmpŠÖ”‚ª‚»‚̔Ɛl‚Å‚·B

	if (strnicmp(disp,(char*)tp+offset,dlen) != 0)
		break;
//	if (CompareString(LOCALE_SYSTEM_DEFAULT,NORM_IGNORECASE,
//		disp,dlen,(char*)tp+offset,dlen) != CSTR_EQUAL)
//		break;

‚±‚ê‚ðŽŸ‚Ì‚æ‚¤‚ÉstrnicmpŠÖ”‚Ì‘ã‚í‚è‚ÉCompareStringŠÖ”‚ð
Žg‚¤‚悤‚ɏC³‚µ‚Ü‚·BƒRƒƒ“ƒg‚ð•t‚¯‘Ö‚¦‚邾‚¯‚Å‚·B
//	if (strnicmp(disp,(char*)tp+offset,dlen) != 0)
//		break;
	if (CompareString(LOCALE_SYSTEM_DEFAULT,NORM_IGNORECASE,
		disp,dlen,(char*)tp+offset,dlen) != CSTR_EQUAL)
		break;


ƒrƒ‹ƒh‚µ‚ăGƒ‰[‚ªÁ‚¦‚ê‚ÎOK‚Å‚·B

ATLƒrƒ‹ƒhŠÂ‹«‚Ì•s‹ï‡‚É‚æ‚érgsƒtƒ@ƒCƒ‹‚̏C³(VC++5.0‚Ì‚Ý) VC++6.0‚Å‚Í•s—v

VC++5.0‚ÌATLƒrƒ‹ƒhŠÂ‹«‚Ì•s‹ï‡‚Ì‚½‚߁ACreateObjectƒƒ\ƒbƒh‚Å Ž¸”s‚·‚邱‚Æ‚ª‚ ‚è‚Ü‚·B
Set obj = Server.CreateObject("FileUp.1")‚¾‚Æ‚¤‚Ü‚­‚¢‚«‚Ü‚·‚ªA Set obj = Server.CreateObject("FileUp")‚¾‚ÆŽ¸”s‚µ‚Ü‚·B ATL ‚̃ŒƒWƒXƒgƒŠ‚Ì“o˜^‚Åversion-independent ProgID‚ÌCLSID‚ª “o˜^‚³‚ê‚È‚¢‚±‚Æ‚ªŒ´ˆö‚Å‚·B DevStudio\SharedIDE\Template\atl‚Ì’†‚Ì*.rgs ƒtƒ@ƒCƒ‹‚Ì’†‚ð ŽŸ‚̂悤‚ɕҏW‚µ‚Ä‚­‚¾‚³‚¢B

	[!ProgID] = s '[!TypeName]'
	{
		CLSID = s '{[!ObjectGUID]}'
[!if=(InsertableEnabled, "TRUE")]
		'Insertable'
[!endif]
	}
	[!VersionIndependentProgID] = s '[!TypeName]'
	{
		CLSID = s '{[!ObjectGUID]}'      <=== ‚±‚̍s‚ð’ljÁ
		CurVer = s '[!ProgID]'
	}


‚±‚ê‚ÅŽŸ‰ñ‚©‚çƒrƒ‹ƒh‚·‚é‚Æ‚«‚ɐ³‚µ‚­“o˜^‚³‚ê‚é‚悤‚É‚È‚è‚Ü‚·B
ƒvƒƒWƒFƒNƒg‚ÌFileUp.rgsƒtƒ@ƒCƒ‹‚ðŽè‚ŕҏW‚µ‚Ä‚à‚©‚Ü‚¢‚Ü‚¹‚ñB
CurVer‚̍s‚Ì‘O‚ÉCLSID‚̍s‚ðŽŸ‚Ì‚æ‚¤‚ɃRƒs[‚µ‚Ä‚­‚¾‚³‚¢B
	FileUp.1 = s 'FileUp Class'
	{
		CLSID = s '{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}'
	}
	FileUp = s 'FileUp Class'
	{
		CLSID = s '{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}'
		CurVer = s 'FileUp.1'
	}



Home


Copyright 1999 Tatsuo Baba,All rights reserved.