我是新來C++我試圖搜索網絡尋求幫助,但沒有成功, 我試圖將參數傳遞給CreateProfileWithIProfAdmin
函數,我想我的原因未能通過它的ARGS,因爲這是其只接受布爾值的布爾類型的函數,但是,我想已經添加(int argc, char *argv[])
到main()
並向CreateProfileWithIProfAdmin
功能,傳遞參數到布爾功能從命令行
,你可以看到倒在函數內部有變量szProfile ,szMailbox等我的目標是直接從命令行通過這些變量與args1 args2等
什麼我nee d是否要將char參數傳遞給函數?
我很新的C++和非常感謝所有幫助,謝謝...
// Function declarations
bool CreateProfileWithIProfAdmin();
void main()
{
CreateProfileWithIProfAdmin();
}
// The Function i want to pass args to.. specifically the 3 chars variables
bool CreateProfileWithIProfAdmin()
{
HRESULT hRes = S_OK; // Result from MAPI calls
LPPROFADMIN lpProfAdmin = NULL; // Profile Admin object
LPSERVICEADMIN lpSvcAdmin = NULL; // Service Admin object
LPMAPITABLE lpMsgSvcTable = NULL; // Table to hold services
LPSRowSet lpSvcRows = NULL; // Rowset to hold results of table query
SPropValue rgval[10]; // Property structure to hold values we want to set
SRestriction sres; // Restriction structure
SPropValue SvcProps; // Property structure for restriction
char szProfile[80] = {0}; // String for profile name
char szMailbox[80] = {0}; // String for mailbox name
char szServer[80] = {0}; // String for server name
// This indicates columns we want returned from HrQueryAllRows
enum {iSvcName, iSvcUID, cptaSvc};
SizedSPropTagArray(cptaSvc,sptCols) = { cptaSvc, PR_SERVICE_NAME, PR_SERVICE_UID };
'main'必須具有返回類型'int',而不是'void'。接下來,你的'CreateProfileWithIProfAdmin'不接受任何參數,'bool'或其他(它有一個'bool'返回類型)。除此之外,你不清楚究竟你想達到什麼目標,因爲你的解釋自相矛盾。 –
*「我不能傳遞參數,因爲它是一個只接受布爾值的布爾類型函數」* - 它返回'bool',就這些。在C++中查找函數。 – LogicStuff
在c + +我必須聲明一個函數的類型?如果是的話,在這種情況下真的需要布爾嗎? – Avshalom