Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
MyStruct.cpp
Package: code_and_note_of_COM.rar [view]
Upload User: weisheen
Upload Date: 2022-07-09
Package Size: 19390k
Code Size: 1k
Category:
ActiveX-DCOM-ATL
Development Platform:
Visual C++
- // MyStruct.cpp : Implementation of CMyStruct
- #include "stdafx.h"
- #include "StructDemo.h"
- #include "MyStruct.h"
- /////////////////////////////////////////////////////////////////////////////
- // CMyStruct
- STDMETHODIMP CMyStruct::GetPersonById(UINT id,StPerson** Result)
- {
- StPerson* p=(StPerson*)::CoTaskMemAlloc(sizeof(StPerson));
- p->age=23;
- p->name=::SysAllocString(L"zhangsan");
- p->sex=::SysAllocString(L"male");
- *Result=p;
- return S_OK;
- }
- STDMETHODIMP CMyStruct::GetAllPerson(UINT* number,StPerson** Result)
- {
- StPerson* p=(StPerson*)::CoTaskMemAlloc(2*sizeof(StPerson));
- ZeroMemory(p,2*sizeof(StPerson));
- p->age=23;
- p->name=::SysAllocString(L"芙蓉");//复制...
- p->sex=::SysAllocString(L"male");
- (p+1)->age=32;
- (p+1)->name=::SysAllocString(L"李松涛");
- (p+1)->sex=::SysAllocString(L"male");
- *Result=p;
- *number=2;
- return S_OK;
- }
- STDMETHODIMP CMyStruct::SavePerson(UINT number,StPerson* Result, UINT* pResult)
- {
- int iResult=0;
- for(int i=0;i<number;i++)
- {
- iResult+=(Result+i)->age;
- }
- *pResult=iResult;
- return S_OK;
- }
- STDMETHODIMP CMyStruct::get_UID(BSTR *pVal)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- // TODO: Add your implementation code here
- *pVal=::SysAllocString(this->m_uid);
- return S_OK;
- }
- STDMETHODIMP CMyStruct::put_UID(BSTR newVal)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState())
- // TODO: Add your implementation code here
- this->m_uid=::SysAllocString(newVal);
- ::SysFreeString(newVal);
- return S_OK;
- }