网格模型

使用.x文件模型(1)

利用.x文件模型渲染三维模型,首先需要将.x文件中的各种数据分别加载到内存中,主要包括顶点数据、材质数据和纹理数据等。

网格模型接口id3dxmesh

Direct3D扩展实用库定义了多边形网格模型接口id3dxmesh来表示一个复杂的三维物体模型,它是一个COM接口,继承自ID3DXBaseMesh。

Direct3D扩展实用库函数D3dxcreateMesh()可用于创建一个Direct3D网格模型对象,该函数声明如下:

Creates a mesh object using a declarator.

HRESULT D3dxcreateMesh( DWORD NumFaces,DWORD NumVertices,DWORD Options,CONST LPD3DVERTEXELEMENT9 * pDeclaration,LPDIRECT3DDEVICE9 pD3DDevice,LPD3DXMESH * ppMesh
);

Parameters

NumFaces
[in] Number of faces for the mesh. The valid range for this number is greater than 0,and one less than the maximum DWORD (typically 65534),because the last index is reserved.
NumVertices
[in] Number of vertices for the mesh. This parameter must be greater than 0.
Options
[in] Combination of one or more flags from the D3DXMESH enumeration,specifying options for the mesh.
pDeclaration
[in] Array of D3DVERTEXELEMENT9 elements,describing the vertex format for the returned mesh. This parameter must map directly to a flexible vertex format (FVF).
pD3DDevice
[in] Pointer to an IDirect3DDevice9 interface,the device object to be associated with the mesh.
ppMesh
[out] Address of a pointer to an id3dxmesh interface,representing the created mesh object.

Return Values

If the function succeeds,the return value is D3D_OK. If the function fails,the return value can be one of the following: D3DERR_INVALIDCALL,E_OUTOFMEMORY.

D3DXMESH

Flags used to specify creation options for a mesh.

typedef enum D3DXMESH
{
    D3DXMESH_32BIT = 0x001,D3DXMESH_DONOTCLIP = 0x002,D3DXMESH_POINTS = 0x004,D3DXMESH_RTPATCHES = 0x008,D3DXMESH_NPATCHES = 0x4000,D3DXMESH_VB_SYstemMEM = 0x010,D3DXMESH_VB_MANAGED = 0x020,D3DXMESH_VB_writeonly = 0x040,D3DXMESH_VB_DYNAMIC = 0x080,D3DXMESH_VB_SOFTWAREPROCESSING = 0x8000,D3DXMESH_IB_SYstemMEM = 0x100,D3DXMESH_IB_MANAGED = 0x200,D3DXMESH_IB_writeonly = 0x400,D3DXMESH_IB_DYNAMIC = 0x800,D3DXMESH_IB_SOFTWAREPROCESSING = 0x10000,D3DXMESH_VB_SHARE = 0x1000,D3DXMESH_USEHWONLY = 0x2000,D3DXMESH_SYstemMEM = 0x110,D3DXMESH_MANAGED = 0x220,D3DXMESH_writeonly = 0x440,D3DXMESH_DYNAMIC = 0x880,D3DXMESH_SOFTWAREPROCESSING = 0x18000,} D3DXMESH,*LPD3DXMESH;

Constants

D3DXMESH_32BIT
The mesh has 32-bit indices instead of 16-bit indices. See Remarks.
D3DXMESH_DONOTCLIP
Use the D3DUSAGE_DONOTCLIP usage flag for vertex and index buffers.
D3DXMESH_POINTS
Use the D3DUSAGE_POINTS usage flag for vertex and index buffers.
D3DXMESH_RTPATCHES
Use the D3DUSAGE_RTPATCHES usage flag for vertex and index buffers.
D3DXMESH_NPATCHES
Specifying this flag causes the vertex and index buffer of the mesh to be created with D3DUSAGE_NPATCHES flag. This is required if the mesh object is to be rendered using N-patch enhancement using Direct3D.
D3DXMESH_VB_SYstemMEM
Use the D3DPOOL_SYstemMEM usage flag for vertex buffers.
D3DXMESH_VB_MANAGED
Use the D3DPOOL_MANAGED usage flag for vertex buffers.
D3DXMESH_VB_writeonly
Use the D3DUSAGE_writeonly usage flag for vertex buffers.
D3DXMESH_VB_DYNAMIC
Use the D3DUSAGE_DYNAMIC usage flag for vertex buffers.
D3DXMESH_VB_SOFTWAREPROCESSING
Use the D3DUSAGE_SOFTWAREPROCESSING usage flag for vertex buffers.
D3DXMESH_IB_SYstemMEM
Use the D3DPOOL_SYstemMEM usage flag for index buffers.
D3DXMESH_IB_MANAGED
Use the D3DPOOL_MANAGED usage flag for index buffers.
D3DXMESH_IB_writeonly
Use the D3DUSAGE_writeonly usage flag for index buffers.
D3DXMESH_IB_DYNAMIC
Use the D3DUSAGE_DYNAMIC usage flag for index buffers.
D3DXMESH_IB_SOFTWAREPROCESSING
Use the D3DUSAGE_SOFTWAREPROCESSING usage flag for index buffers.
D3DXMESH_VB_SHARE
Forces the cloned meshes to share vertex buffers.
D3DXMESH_USEHWONLY
Use hardware processing only. For mixed-mode device,this flag will cause the system to use hardware (if supported in hardware) or will default to software processing.
D3DXMESH_SYstemMEM
Equivalent to specifying both D3DXMESH_VB_SYstemMEM and D3DXMESH_IB_SYstemMEM.
D3DXMESH_MANAGED
Equivalent to specifying both D3DXMESH_VB_MANAGED and D3DXMESH_IB_MANAGED.
D3DXMESH_writeonly
Equivalent to specifying both D3DXMESH_VB_writeonly and D3DXMESH_IB_writeonly.
D3DXMESH_DYNAMIC
Equivalent to specifying both D3DXMESH_VB_DYNAMIC and D3DXMESH_IB_DYNAMIC.
D3DXMESH_SOFTWAREPROCESSING
Equivalent to specifying both D3DXMESH_VB_SOFTWAREPROCESSING and D3DXMESH_IB_SOFTWAREPROCESSING.

Remarks

A 32-bit mesh (D3DXMESH_32BIT) can theoretically support (2^32)-1 faces and vertices. However,allocating memory for a mesh that large on a 32-bit operating system is not practical.

一般情况下,参数Option置为D3DMESH_SYstemMEM或D3DMESH_MANAGED,表示对Direct3D顶点缓冲区和索引缓冲区使用D3DPOOL_SYstemMEM或D3DPOOL_MANAGED内存。

调用D3dxcreateMesh()函数创建了网格模型对象后,还需要为其载入模型数据,而载入模型数据是比较复杂的。所以在大多数情况下,不直接调用函数,它被封装在Direct3D扩展实用库函数中,由Direct3D在内部完成网格模型对象的创建和模型数据的载入操作。

通过.x文件生成网格模型

复杂的三维模型实际上是由许许多多的多边形构成的,所以首先需要得到这些构成模型的多边形。使用Direct3D功能扩展库函数D3DXLoadMeshFromX(),可以从.X文件提取多边形信息(包括顶点坐标、颜色、法向量和纹理信息等),生成网格模型。该函数的声明如下:

Loads a mesh from a DirectX .x file.

HRESULT D3DXLoadMeshFromX( LPCTSTR pFilename,LPD3DXBUFFER * ppAdjacency,LPD3DXBUFFER * ppMaterials,LPD3DXBUFFER * ppEffectInstances,DWORD * pNumMaterials,LPD3DXMESH * ppMesh
);

Parameters

pFilename
[in] Pointer to a string that specifies the filename. If the compiler settings require Unicode,the data type LPCTSTR resolves to LPCWSTR. Otherwise,the string data type resolves to LPCSTR. See Remarks.
Options
[in] Combination of one or more flags from the D3DXMESH enumeration,which specifies creation options for the mesh.
pD3DDevice
[in] Pointer to an IDirect3DDevice9 interface,the device object associated with the mesh.
ppAdjacency
[out] Pointer to a buffer that contains adjacency data. The adjacency data contains an array of three DWORDs per face that specify the three neighbors for each face in the mesh. For more information about accessing the buffer,see ID3DXBuffer.
ppMaterials
[out] Pointer to a buffer containing materials data. The buffer contains an array of D3DXMATERIAL structures,containing information from the DirectX file. For more information about accessing the buffer,see ID3DXBuffer.
ppEffectInstances
[out] Pointer to a buffer containing an array of effect instances,one per attribute group in the returned mesh. An effect instance is a particular instance of state information used to initialize an effect. See D3DXEFFECTINSTANCE. For more information about accessing the buffer,see ID3DXBuffer.
pNumMaterials
[out] Pointer to the number of D3DXMATERIAL structures in the ppMaterials array,when the method returns.
ppMesh
[out] Address of a pointer to an id3dxmesh interface,representing the loaded mesh.

Return Values

If the function succeeds,the return value can be one of the following values: D3DERR_INVALIDCALL,E_OUTOFMEMORY.

Remarks

The compiler setting also determines the function version. If Unicode is defined,the function call resolves to D3DXLoadMeshFromXW. Otherwise,the function call resolves to D3DXLoadMeshFromXA because ANSI strings are being used.

All the meshes in the file will be collapsed into one output mesh. If the file contains a frame hierarchy,all the transformations will be applied to the mesh.

For mesh files that do not contain effect instance information,default effect instances will be generated from the material information in the .x file. A default effect instance will have default values that correspond to the members of the D3DMATERIAL9 structure.

The default texture name is also filled in,but is handled differently. The name will be Texture0@Name,which corresponds to an effect variable by the name of "Texture0" with an annotation called "Name." This will contain the string file name for the texture.

LPD3DXBUFFER因数据操作的方便性而诞生,它的好处是可以存储顶点位置坐标、材质、纹理等多种类型的Direct3D数据,而不必对每种数据声明一种函数接口类型。可使用接口函数ID3DXBuffer::GetBufferPointer()获取缓冲区中的数据,使用ID3DXBuffer::GetBufferSize()获取缓冲区数据大小。

载入材质和纹理

如果函数D3DXLoadMeshFromX()调用成功,那么参数ppMaterials就会获取.x文件中三维模型导出的材质和纹理信息,而pNumMaterials则会获得材质的数目,将材质和纹理信息从中提取出来的代码如下:

bool init_geometry()
{
	ID3DXBuffer* material_buffer;
	/*
	 D3DXLoadMeshFromXA(
        LPCSTR pFilename,DWORD Options,LPDIRECT3DDEVICE9 pD3DDevice,LPD3DXBUFFER *ppAdjacency,LPD3DXBUFFER *ppMaterials,LPD3DXBUFFER *ppEffectInstances,DWORD *pNumMaterials,LPD3DXMESH *ppMesh);
	*/
	if(Failed(D3DXLoadMeshFromX("airplane.x",D3DXMESH_MANAGED,g_device,NULL,&material_buffer,&g_num_materials,&g_mesh)))
	{
		MessageBox(NULL,"Could not find airplane.x","ERROR",MB_OK);
		return false;
	}
	D3DXMATERIAL* xmaterials = (D3DXMATERIAL*) material_buffer->GetBufferPointer();
	g_mesh_materials = new D3DMATERIAL9[g_num_materials];
	g_mesh_textures	 = new IDirect3DTexture9*[g_num_materials];
	for(DWORD i = 0; i < g_num_materials; i++)
	{
		g_mesh_materials[i] = xmaterials[i].MatD3D;
		// set ambient reflected coefficient,because .x file do not set it.
		g_mesh_materials[i].Ambient = g_mesh_materials[i].Diffuse;
		g_mesh_textures[i] = NULL;
		if(xmaterials[i].pTextureFilename != NULL && strlen(xmaterials[i].pTextureFilename) > 0)	
			D3dxcreateTextureFromFile(g_device,xmaterials[i].pTextureFilename,&g_mesh_textures[i]);	
	}
	material_buffer->Release();
	return true;
}

一个三维网格模型通常是由几个子模型组成的,在制作模型时通常为每个子模型分别设置材质和纹理,所以这些子模型就可能使用不同的材质和纹理,因此在Direct3D程序就需要为所有的子模型分别保存材质和纹理。此外,因为每个子模型可能具有不同的材质和纹理,所以在渲染三维模型时也需要逐个子模型分别进行渲染。

渲染网格模型

网格模型接口id3dxmesh实际上是三维物体的顶点缓冲区的集合,它将创建顶点缓冲区、定义灵活顶点格式和绘制顶点缓冲区等功能封装在一个COM对象里,极大地方便了三维物体的绘制。对于以id3dxmesh表示的三维物体,可以遍历它所有的顶点缓冲区,按照相应的顶点格式将它们分别渲染,也可以直接调用它的接口函数id3dxmesh::DrawSubset()绘制图形,该函数的声明如下:

Draws a subset of a mesh.

HRESULT DrawSubset( DWORD AttribId
);

Parameters

AttribId
[in] DWORD that specifies which subset of the mesh to draw. This value is used to differentiate faces in a mesh as belonging to one or more attribute groups.

Return Values

If the method succeeds,the return value is D3D_OK. If the method fails,the return value can be D3DERR_INVALIDCALL.

Remarks

The subset that is specified by AttribId will be rendered by the IDirect3DDevice9::DrawIndexedPrimitive method,using the D3DPT_TRIANGLELIST primitive type,so an index buffer must be properly initialized.

An attribute table is used to identify areas of the mesh that need to be drawn with different textures,render states,materials,and so on. In addition,the application can use the attribute table to hide portions of a mesh by not drawing a given attribute identifier (AttribId) when drawing the frame.

渲染网格模型的代码如下:

void render()
{
	g_device->Clear(0,D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,D3DCOLOR_X#050505,1.0f,0);
	g_device->BeginScene();
	setup_world_matrix();
	for(DWORD i = 0; i < g_num_materials; i++)
	{
		g_device->SetMaterial(&g_mesh_materials[i]);
		g_device->SetTexture(0,g_mesh_textures[i]);
		g_mesh->DrawSubset(i);
	}
	
	g_device->EndScene();
	g_device->Present(NULL,NULL);
}
 
源程序:

#include <d3dx9.h>

#pragma warning(disable : 4127)

#define CLASS_NAME    "GameApp"

#define release_com(p)    do { if(p) { (p)->Release(); (p) = NULL; } } while(0)

IDirect3D9*                g_d3d;
IDirect3DDevice9*        g_device;
id3dxmesh*                g_mesh;
D3DMATERIAL9*            g_mesh_materials;
IDirect3DTexture9**        g_mesh_textures;
DWORD                    g_num_materials;

void setup_world_matrix()
{
    D3DXMATRIX mat_world;    
    D3DXMatrixRotationY(&mat_world,timeGetTime() / 1000.0f);
    g_device->SetTransform(D3DTS_WORLD,&mat_world);
}

void setup_view_proj_matrix()
{
    // setup view matrix

    D3DXVECTOR3 eye(0.0f,10.0f,-20.0f);
    D3DXVECTOR3 at(0.0f,0.0f,0.0f);
    D3DXVECTOR3 up(0.0f,0.0f);

    D3DXMATRIX mat_view;
    D3DXMatrixLookAtLH(&mat_view,&eye,&at,&up);
    g_device->SetTransform(D3DTS_VIEW,&mat_view);

    // setup projection matrix

    D3DXMATRIX mat_proj;
    D3DXMatrixPerspectiveFovLH(&mat_proj,D3DX_PI/4,100.0f);
    g_device->SetTransform(D3DTS_PROJECTION,&mat_proj);
}

bool init_geometry()
{
    ID3DXBuffer* material_buffer;

    /*
     D3DXLoadMeshFromXA(
        LPCSTR pFilename,LPD3DXMESH *ppMesh);
    */

    if(Failed(D3DXLoadMeshFromX("airplane.x",&g_mesh)))
    {
        MessageBox(NULL,MB_OK);
        return false;
    }

    D3DXMATERIAL* xmaterials = (D3DXMATERIAL*) material_buffer->GetBufferPointer();

    g_mesh_materials = new D3DMATERIAL9[g_num_materials];
    g_mesh_textures     = new IDirect3DTexture9*[g_num_materials];

    for(DWORD i = 0; i < g_num_materials; i++)
    {
        g_mesh_materials[i] = xmaterials[i].MatD3D;

        // set ambient reflected coefficient,because .x file do not set it.
        g_mesh_materials[i].Ambient = g_mesh_materials[i].Diffuse;

        g_mesh_textures[i] = NULL;

        if(xmaterials[i].pTextureFilename != NULL && strlen(xmaterials[i].pTextureFilename) > 0)    
            D3dxcreateTextureFromFile(g_device,&g_mesh_textures[i]);    
    }

    material_buffer->Release();

    return true;
}

bool init_d3d(HWND hwnd)
{
    g_d3d = Direct3DCreate9(D3D_SDK_VERSION);

    if(g_d3d == NULL)
        return false;

    D3DPRESENT_ParaMETERS d3dpp;
    ZeroMemory(&d3dpp,sizeof(d3dpp));

    d3dpp.Windowed                    = TRUE;
    d3dpp.SwapEffect                = D3DSWAPEFFECT_disCARD;
    d3dpp.BackBufferFormat            = D3DFMT_UNKNowN;
    d3dpp.EnableAutoDepthStencil    = TRUE;
    d3dpp.AutoDepthStencilFormat    = D3DFMT_D16;

    if(Failed(g_d3d->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,hwnd,D3DCREATE_SOFTWARE_VERTEXPROCESSING,&d3dpp,&g_device)))
    {
        return false;
    }
    
    if(! init_geometry())
        return false;

    setup_view_proj_matrix();    

    g_device->SetRenderState(D3DRS_LIGHTING,FALSE);    
    
    return true;
}

void cleanup()
{
    delete[] g_mesh_materials;

    if(g_mesh_textures)
    {
        for(DWORD i = 0; i < g_num_materials; i++)
            release_com(g_mesh_textures[i]);

        delete[] g_mesh_textures;
    }
    
    release_com(g_mesh);
    release_com(g_device);
    release_com(g_d3d);
}

void render()
{
    g_device->Clear(0,D3DCOLOR_XRGB(5,5,5),0);

    g_device->BeginScene();

    setup_world_matrix();

    for(DWORD i = 0; i < g_num_materials; i++)
    {
        g_device->SetMaterial(&g_mesh_materials[i]);
        g_device->SetTexture(0,g_mesh_textures[i]);

        g_mesh->DrawSubset(i);
    }
    
    g_device->EndScene();

    g_device->Present(NULL,NULL);
}

LRESULT WINAPI WinProc(HWND hwnd,UINT msg,WParaM wParam,LParaM lParam)
{
    switch(msg)
    {
    case WM_KEYDOWN:
        if(wParam == VK_ESCAPE)
            DestroyWindow(hwnd);
        break;

    case WM_DESTROY:        
        PostQuitMessage(0);
        return 0;
    }

    return DefWindowProc(hwnd,msg,wParam,lParam);
}

int WINAPI WinMain(HINSTANCE inst,HINSTANCE,LPSTR,INT)
{
    WNDCLASSEX wc;

    wc.cbSize            = sizeof(WNDCLASSEX);
    wc.style            = CS_CLASSDC;
    wc.lpfnWndProc        = WinProc;
    wc.cbClsExtra        = 0;
    wc.cbWndExtra        = 0;
    wc.hInstance        = inst;
    wc.hIcon            = NULL;
    wc.hCursor            = NULL;
    wc.hbrBackground    = NULL;
    wc.lpszMenuName        = NULL;
    wc.lpszClassName    = CLASS_NAME;
    wc.hIconSm            = NULL;

    if(! RegisterClassEx(&wc))
        return -1;

    HWND hwnd = CreateWindow(CLASS_NAME,"Direct3D App",WS_OVERLAPPEDWINDOW,200,100,640,480,wc.hInstance,NULL);    

    if(hwnd == NULL)
        return -1;

    if(init_d3d(hwnd))
    {
        ShowWindow(hwnd,SW_SHOWDEFAULT);
        UpdateWindow(hwnd);

        MSG msg;
        ZeroMemory(&msg,sizeof(msg));

        while(msg.message != WM_QUIT)
        {
            if(PeekMessage(&msg,PM_REMOVE))
            {
                TranslateMessage(&msg);
                dispatchMessage(&msg);
            }
                
            render();
        }
    }

    cleanup();
    UnregisterClass(CLASS_NAME,wc.hInstance);    

    return 0;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Format[$] ( expr [ , fmt ] ) format 返回变体型 format$ 强制返回为文本 -------------------------------- 数字类型的格式化 --------------------------------     固定格式参数:     General Number 普通数字,如可以用来去掉千位分隔号     format$("100,1
VB6或者ASP 格式化时间为 MM/dd/yyyy 格式,竟然没有好的办法, Format 或者FormatDateTime 竟然结果和系统设置的区域语言的日期和时间格式相关。意思是尽管你用诸如 Format(Now, "MM/dd/yyyy"),如果系统的设置格式区域语言的日期和时间格式分隔符是"-",那他还会显示为 MM-dd-yyyy     只有拼凑: <%response.write
在项目中添加如下代码:新建窗口来显示异常信息。 Namespace My ‘全局错误处理,新的解决方案直接添加本ApplicationEvents.vb 到工程即可 ‘添加后还需要一个From用来显示错误。如果到这步还不会则需要先打好基础啦 ‘======================================================== ‘以下事件
转了这一篇文章,原来一直想用C#做k3的插件开发,vb没有C#用的爽呀,这篇文章写与2011年,看来我以前没有认真去找这个方法呀。 https://blog.csdn.net/chzjxgd/article/details/6176325 金蝶K3 BOS的插件官方是用VB6编写的,如果  能用.Net下的语言工具开发BOS插件是一件很愉快的事情,其中缘由不言而喻,而本文则是个人首创,实现在了用V
Sub 分列() ‘以空格为分隔符,连续空格只算1个。对所选中的单元格进行处理 Dim m As Range, tmpStr As String, s As String Dim x As Integer, y As Integer, subStr As String If MsgBox("确定要分列处理吗?请确定分列的数据会覆盖它后面的单元格!", _
  窗体代码 1 Private Sub Text1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single) 2 Dim path As String, hash As String 3 For Each fil
  Imports MySql.Data.MySqlClient Public Class Form1 ‘ GLOBAL DECLARATIONS Dim conString As String = "Server=localhost;Database=net2;Uid=root;Pwd=123456;" Dim con As New MySqlConnection
‘導入命名空間 Imports ADODB Imports Microsoft.Office.Interop   Private Sub A1() Dim Sql As String Dim Cnn As New ADODB.Connection Dim Rs As New ADODB.Recordset Dim S As String   S = "Provider=OraOLEDB.Oracl
Imports System.IO Imports System.Threading Imports System.Diagnostics Public Class Form1 Dim A(254) As String    Function ping(ByVal IP As Integer) As String Dim IPAddress As String IPAddress = "10.0.
VB运行EXE程序,并等待其运行结束 参考:https://blog.csdn.net/useway/article/details/5494084 Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long Pr
今天碰到一个问题,登陆的时候,如果不需要验证手机号为空,则不去验证手机号 因为登陆的时候所有的验证信息都存放在一个数组里 Dim CheckUserInfo() As String ={UserBirthday, SecEmail, UserMob, UserSex, RealNameFirst, RealName, CheckCardID, CheckCardType, Contactemail
在VB6.0中,数据访问接口有三种: 1、ActiveX数据对象(ADO) 2、远程数据对象(RDO) 3、数据访问对象(DAO) 1.使用ADO(ActiveX Data Objec,ActiveX数据对象)连接SQL Server 1)使用ADO控件连接 使用ADO控件的ConnectionString属性就可以连接SQL Server,该属性包含一个由分号分隔的argument=value语
注:大家如果没有VB6.0的安装文件,可自行百度一下下载,一般文件大小在200M左右的均为完整版的软件,可以使用。   特别提示:安装此软件的时候最好退出360杀毒软件(包括360安全卫士,电脑管家等,如果电脑上有这些软件的话),因为现如今的360杀毒软件直接会对VB6.0软件误报,这样的话就可能会在安装过程中被误报阻止而导致安装失败,或者是安装后缺乏很多必须的组件(其它的杀毒软件或安全卫士之类的
Private Sub Form_Load() Call conndb End Sub Private Function conndb() Dim cn As New ADODB.Connection Dim rs As New ADODB.Recordset Dim strCn, sql As String Dim db_host As String Dim db_user As String
  PPSM06S70:  Add  moddate  EDITSPRINTJOB:  MAX(TO_CHAR(ETRN.MODDATE, ‘yyyy/mm/dd/HH24:MI AM‘)) ACTUAL_SHIPDATE   4.Test Scenario (1) :Query SQL Test DN:8016578337 SELECT CTRN.TKCTID TRUCK_ID,        
  沒有出現CrystalReportViewer時,須安裝CRforVS_13_0. 新增1個數據集,新增1個數據表,添加二列,列名要和資料庫名一樣. 修改目標Framework 修改app.config, <startup >改成<startup useLegacyV2RuntimeActivationPolicy ="true">  CrystalReport1.rpt增加數據庫專家 在表單
Imports System.Threading Imports System Public Class Form1 Dim th1, th2 As Thread Public Sub Method1() Dim i As Integer For i = 1 To 100 If Me.Label1.BackColor =
Friend Const PROCESS_ALL_ACCESS = &H1F0FFF = 2035711 Friend Const PROCESS_VM_READ = &H10 Friend Const PROCESS_VM_WRITE = &H20 Friend Const PAGE_READONLY = &H2 Friend Const PAGE_READWRITE = &H4 Friend
以下代码随手写的 并没有大量测试 效率也有待提升 如果需要C#的请自行转换 Function SplitBytes(Data As Byte(), Delimiter As Byte()) As List(Of Byte()) Dim i = 0 Dim List As New List(Of Byte()) Dim bytes As New
Imports System.Data.SqlClient Public Class Form1 REM Public conn1 As SqlConnection = New SqlConnection("server=.; Integrated Security=False;Initial Catalog= mydatabase1; User ID= sa;password")