DWORD dwProcs[1024*2]; 阅读全文
DWORD dwNeeded;
EnumProcesses( dwProcs, sizeof(dwProcs), &dwNeeded );
DWORD dwProcCount = dwNeeded / sizeof(DWORD);
char temp[50]; 阅读全文
HANDLE hPrinter = NULL;
DWORD dwNeeded = 0;
DWORD dwReturned = 0;
JOB_INFO_1 *pJobInfo = NULL;
int n = 0;
int ret = OpenPrinter(“\\\\192.168.10.13\\Canon MX310 series Printer”, &hPrinter, NULL);
if(ret == 0)
{
p->MessageBox(“打开打印机失败!”);
return 0;
}
char RemoteName[] = “\\\\192.168.105.9″; 阅读全文
DWORD ret;
NETRESOURCE nr;
memset(&nr, 0, sizeof(nr));
nr.dwScope = RESOURCE_CONNECTED;
nr.dwType = RESOURCETYPE_ANY;
nr.dwDisplayType = RESOURCEDISPLAYTYPE_GENERIC;
nr.dwUsage = RESOURCEUSAGE_CONNECTABLE;
nr.lpRemoteName = RemoteName;
ret = WNetAddConnection2(&nr, NULL, NULL, CONNECT_UPDATE_PROFILE);
DWORD WINAPI Start(LPVOID lParam) 阅读全文
{
CPostDlg *p = (CPostDlg *)lParam;
SOCKET sock = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP);
if(sock == SOCKET_ERROR)
{
p->MessageBox(“创建套接字失败~”);
return 0;
}
SOCKADDR_IN addr;
addr.sin_family = AF_INET;
addr.sin_port = htons(80);
char url[20] = “192.168.10.104″;
DWORD WINAPI MyThread(LPVOID lParam)
{
CTestDlg *p = (CTestDlg *)lParam;
char path[1024]; 阅读全文
char cmdline[1024];
char buffer[1024];
memset(buffer, 0, sizeof(buffer));
memset(cmdline, 0, sizeof(cmdline));
memset(path, 0, sizeof(path));
::GetSystemDirectory(path, sizeof(path));
WSADATA wsa;
WSAStartup(MAKEWORD(2,2),&wsa);
hostent *pht;
pht=gethostbyname(“www.lingdux.com”);
LPSTR pstr=pht->h_addr_list[0];
struct in_addr inaddr;
memmove(&inaddr,pstr,4);
MessageBoxA(0,inet_ntoa(inaddr),0,0);
CFtpConnection *pconnection;
CInternetSession *session=new CInternetSession(AfxGetAppName(),1,PRE_CONFIG_INTERNET_ACCESS);
try
{
pconnection=session->GetFtpConnection(FtpAddress,UserName,Password);
}
catch(CInternetException *pEx)
{
WCHAR errror[1024]={0};
if(pEx->GetErrorMessage(ERROR,1024))
MessageBox(ERROR);
else
MessageBox(L”出现异常”);
}
if(pconnection->PutFile(L”C:\\ip.txt”,path))
MessageBox(L”上传成功!”);
else
MessageBox(L”上传失败!”);
pconnection->Close();
#include “windows.h”
#include “tchar.h”
WCHAR a[]=L”123″;
int WINAPI MyFonc(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
WCHAR b[]=L”456″;
HMODULE hmodule=LoadLibrary(L”user32.dll”);
FARPROC addr=GetProcAddress(hmodule,”MessageBoxW”);
__asm
{
push 0
mov eax,offset a//全局用offset
push eax
lea eax,b//局部用lea
push eax
push 0
call addr
}
return 0;
}
#ifdef NDEBUG
#pragma optimize(“gsy”,on)
//RELEASE方式编译
#pragma comment(linker,”/RELEASE”)
#ifdef _MERGE_RDATA_
//合并区段
#pragma comment(linker,”/merge:.rdata=.text”)
#endif
#pragma comment(linker,”/merge:.data=.text”)
#pragma comment(linker,”/merge:.reloc=.text”)
#if _MSC_VER>=1000
#endif
#endif